e955. setting the activation click count for a table cell editor in a jtable component.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 26 行

TXT
26
字号
By default, a table cell editor is activated with a double-click. The activation behavior is controlled by the renderer, not by a table property. To change this, override the isCellEditable() method of the editor. See e953 Creating a Custom Table Cell Editor in a JTable Component for more information about table cell editors. 
    
    public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
        // See e953 Creating a Custom Table Cell Editor in a JTable Component
        // for other methods that need to be implemented.
    
        public boolean isCellEditable(EventObject evt) {
            if (evt instanceof MouseEvent) {
                int clickCount;
    
                // For single-click activation
                clickCount = 1;
    
                // For double-click activation
                clickCount = 2;
    
                // For triple-click activation
                clickCount = 3;
    
                return ((MouseEvent)evt).getClickCount() >= clickCount;
            }
            return true;
        }
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?