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


Java JTable.convertColumnIndexToModel方法代码示例

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


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

示例1: validate

import javax.swing.JTable; //导入方法依赖的package包/类
private void validate(int viewRow, int viewCol) {
    JTable table = (JTable) getComponent();
    try {
        int row = table.convertRowIndexToModel(viewRow);
        int col = table.convertColumnIndexToModel(viewCol);
        TableModel model = table.getModel();
        if (row >= 0 && row < model.getRowCount() && col >= 0 && col < model.getColumnCount()) {
            if (table.isCellEditable(viewRow, viewCol)) {
                return;
            } else {
                throw new NoSuchElementException("The cell is not editable on JTable: (" + viewRow + ", " + viewCol + ")",
                        null);
            }
        }
    } catch (IndexOutOfBoundsException e) {
    }
    throw new NoSuchElementException("Invalid row/col for JTable: (" + viewRow + ", " + viewCol + ")", null);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:JTableJavaElement.java

示例2: addMouseListenerToHeaderInTable

import javax.swing.JTable; //导入方法依赖的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,项目名称:Neukoelln_SER316,代码行数:27,代码来源:TableSorter.java

示例3: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row,
        int column) {

    Component c =
        tableCellRenderer.getTableCellRendererComponent(table, value,
            isSelected, hasFocus, row, column);

    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;

        l.setHorizontalTextPosition(JLabel.LEFT);

        int modelColumn = table.convertColumnIndexToModel(column);

        l.setIcon(getHeaderRendererIcon(modelColumn,
                                        l.getFont().getSize()));
    }

    return c;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:TableSorter.java

示例4: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
    Component c = tableCellRenderer.getTableCellRendererComponent(table,
            value, isSelected, hasFocus, row, column);
    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;
        l.setHorizontalTextPosition(JLabel.LEFT);
        int modelColumn = table.convertColumnIndexToModel(column);
        l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TableSorter.java

示例5: getTableCellEditorComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
    oldValue = value;
    int modelColumn = table.convertColumnIndexToModel(column);
    TableModel tm = table.getModel();
    dbColumn = null;
    if (tm instanceof ResultSetTableModel) {
        textField.setInputVerifier(verifier);
        dbColumn = ((ResultSetTableModel) tm).getColumn(modelColumn);
    } else {
        textField.setInputVerifier(null);
    }
    Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
    if (suppressEditorBorder && c instanceof JComponent) {
        ((JComponent) c).setBorder(BorderFactory.createEmptyBorder());
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NumberFieldEditor.java

示例6: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader header = (JTableHeader) e.getSource();
    JTable table = header.getTable();
    TableColumnModel columnModel = table.getColumnModel();
    int vci = columnModel.getColumnIndexAtX(e.getX());
    int mci = table.convertColumnIndexToModel(vci);
    if (mci == targetColumnIndex) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            TableColumn column = columnModel.getColumn(vci);
            Object v = column.getHeaderValue();
            boolean b = Status.DESELECTED.equals(v);
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                m.setValueAt(b, i, mci);
            }
            column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
        } else if (SwingUtilities.isRightMouseButton(e)) {
            if (popupMenu != null) {
                popupMenu.show(table, e.getX(), 0);
            }
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:TableCheckBoxColumn.java

示例7: addMouseListenerToHeaderInTable

import javax.swing.JTable; //导入方法依赖的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

示例8: addMouseListenerToHeaderInTable

import javax.swing.JTable; //导入方法依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TableSorter.java

示例9: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component renderer;
    int modelColumnIndex = table.convertColumnIndexToModel(column);
    DiffNode node = null;
    if (modelColumnIndex == 0) {
        node = tableModel.getNode(table.convertRowIndexToModel(row));
        String htmlDisplayName = DiffUtils.getHtmlDisplayName(node, isModified(node.getFile()), isSelected);
        if (node.isExcluded()) {
            htmlDisplayName = "<s>" + (htmlDisplayName == null ? node.getFileNode().getName() : htmlDisplayName) + "</s>"; //NOI18N
        }
        if (htmlDisplayName != null) {
            value = "<html>" + htmlDisplayName;                 //NOI18N
        }
    }
    if (modelColumnIndex == 2) {
        renderer = pathRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    } else {
        renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    }
    if (renderer instanceof JComponent) {
        if (node == null) {
            node = tableModel.getNode(table.convertRowIndexToModel(row));
        }
        String path = node.getFile().getAbsolutePath();
        ((JComponent) renderer).setToolTipText(path);
    }
    return renderer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DiffFileTable.java

示例10: getTableCellEditorComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, final int column) {
    final JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row, column);      
    
    this.tableModel = table.getModel();
    this.columnName = table.getColumnName(column);
    this.modelRow = table.convertRowIndexToModel(row);
    this.modelColumn = table.convertColumnIndexToModel(column);  
    this.tc = c instanceof JTextComponent ? (JTextComponent) c : null;

    JPanel panel = new JPanel(new BorderLayout()) {
        @Override
        public void addNotify() {
            super.addNotify();
            c.requestFocus();
        }
    };
    panel.add(c);
    if (suppressEditorBorder) {
        c.setBorder(BorderFactory.createEmptyBorder());
    }
    panel.add(customEditorButton, BorderLayout.EAST);
    panel.revalidate();
    panel.repaint();

    return panel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:StringTableCellEditor.java

示例11: validateRowCol

import javax.swing.JTable; //导入方法依赖的package包/类
private void validateRowCol() {
    JTable table = (JTable) parent.getComponent();
    try {
        int row = table.convertRowIndexToModel(viewRow);
        int col = table.convertColumnIndexToModel(viewCol);
        TableModel model = table.getModel();
        if (row >= 0 && row < model.getRowCount() && col >= 0 && col < model.getColumnCount()) {
            return;
        }
    } catch (IndexOutOfBoundsException e) {
    }
    throw new NoSuchElementException("Invalid row/col for JTable: (" + viewRow + ", " + viewCol + ")", null);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JTableCellJavaElement.java

示例12: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
	boolean hasFocus, int row, int column)
{
	Component c = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
		column);
	if( c instanceof JLabel )
	{
		JLabel l = (JLabel) c;
		l.setHorizontalTextPosition(SwingConstants.LEFT);
		int modelColumn = table.convertColumnIndexToModel(column);
		l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
	}
	return c;
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:TableSorter.java


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