当前位置: 首页>>代码示例>>Java>>正文


Java TableColumnModel.getColumnIndexAtX方法代码示例

本文整理汇总了Java中javax.swing.table.TableColumnModel.getColumnIndexAtX方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumnModel.getColumnIndexAtX方法的具体用法?Java TableColumnModel.getColumnIndexAtX怎么用?Java TableColumnModel.getColumnIndexAtX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.TableColumnModel的用法示例。


在下文中一共展示了TableColumnModel.getColumnIndexAtX方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = columnModel.getColumnIndexAtX(e.getX());
	int column = columnModel.getColumn(viewColumn).getModelIndex();
	if (column != -1) {
		int status = getSortingStatus(column);
		if (!e.isControlDown()) {
			cancelSorting();
		}
		// Cycle the sorting states through {NOT_SORTED, ASCENDING,
		// DESCENDING} or
		// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether
		// shift is pressed.
		status = status + (e.isShiftDown() ? -1 : 1);
		status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0,
										// 1}
		setSortingStatus(column, status);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:TableSorter.java

示例2: addMouseListenerToHeaderInTable

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:27,代码来源:TableSorter.java

示例3: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TableSorter.java

示例4: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	if (!e.isPopupTrigger()) {
		JTableHeader h = (JTableHeader) e.getSource();
		TableColumnModel columnModel = h.getColumnModel();
		int viewColumn = columnModel.getColumnIndexAtX(e.getX());
		int column = columnModel.getColumn(viewColumn).getModelIndex();
		if (column != -1) {
			if (columnModel.getColumn(viewColumn).getHeaderValue().equals("File Name")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_NAME, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Type")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_TYPE, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Last Modified")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_MODIFIED, false);
				FileTable.this.fileList.updateTableData();
			} else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Size")) {
				FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_SIZE, false);
				FileTable.this.fileList.updateTableData();
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:FileTable.java

示例5: mousePressed

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	if (!SwingUtilities.isLeftMouseButton(e)) {
		return;
	}
	super.mousePressed(e);

	if (header.getResizingColumn() == null) {
		Point p = e.getPoint();
		TableColumnModel columnModel = header.getColumnModel();
		int index = columnModel.getColumnIndexAtX(p.x);
		if (index != -1) {
			if (header.editCellAt(index, e)) {
				setDispatchComponent(e);
				repostEvent(e);
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:EditableTableHeaderUI.java

示例6: mouseMoved

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent evt) {
	TableColumn col = null;
	JTableHeader header = (JTableHeader) evt.getSource();
	JTable table = header.getTable();
	TableColumnModel colModel = table.getColumnModel();
	int vColIndex = colModel.getColumnIndexAtX(evt.getX());

	// Return if not clicked on any column header
	if (vColIndex >= 0) {
		col = colModel.getColumn(vColIndex);
	}

	if (col != curCol) {
		header.setToolTipText(tips.get(col));
		curCol = col;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:19,代码来源:ColumnHeaderToolTips.java

示例7: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent evt) {
    // XXX Benchmark sort performance
    //long start = System.currentTimeMillis();
    CommonUI.setWaitCursor(SwingUtilities.getRoot(table));

    TableColumnModel columnModel = table.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(evt.getX());
    int column = table.convertColumnIndexToModel(viewColumn);
    if (evt.getClickCount() == 1 && column != -1) {
        // Reverse the sorting direction.
        model.sortByColumn(column, !model.isAscending());
    }

    // XXX Benchmark performance
    //      System.out.println("Sort time: " +
    //         (System.currentTimeMillis() - start));
    CommonUI.setDefaultCursor(SwingUtilities.getRoot(table));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:SortHeaderMouseAdapter.java

示例8: addMouseListenerToHeaderInTable

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //Util.debug("Sorting ...");
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:27,代码来源:TableSorter.java

示例9: addMouseListenerToHeaderInTable

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                System.out.println("Sorting ...");
                int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
                boolean ascending = (shiftPressed == 0);
                sorter.sortByColumn(column, ascending);
            }
        }
    };
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TableSorter.java

示例10: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e)
{
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = columnModel.getColumnIndexAtX(e.getX());
	int column = columnModel.getColumn(viewColumn).getModelIndex();
	if( column != -1 )
	{
		int status = getSortingStatus(column);
		if( !e.isControlDown() )
		{
			cancelSorting();
		}
		// Cycle the sorting states through {NOT_SORTED, ASCENDING,
		// DESCENDING} or
		// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether
		// shift is pressed.
		status = status + (e.isShiftDown() ? -1 : 1);
		status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0,
		// 1}
		setSortingStatus(column, status);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:TableSorter.java

示例11: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {

            JTableHeader     h           = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = columnModel.getColumn(viewColumn).getModelIndex();

            if (column != -1) {
                int status = getSortingStatus(column);

                if (!e.isControlDown()) {
                    cancelSorting();
                }

                // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                status = status + (e.isShiftDown() ? -1
                                                   : 1);
                status = (status + 4) % 3 - 1;    // signed mod, returning {-1, 0, 1}

                setSortingStatus(column, status);
            }
        }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:TableSorter.java


注:本文中的javax.swing.table.TableColumnModel.getColumnIndexAtX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。