當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。