⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e958. disabling user edits in a jtable component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
User editing can be disabled in two places. By disabling edits in the model, no table component using that model will allow editing by the user. By disabling edits in the table component, only that component disallows edits; other table components using the same model will allow editing. 
Disabling edits requires subclassing either the JTable or TableModel class. 

Note: Although user editing is disabled, programmatically changing values in the model is still possible. 

    // Create a JTable that disallow edits
    JTable table1 = new JTable() {
        public boolean isCellEditable(int rowIndex, int vColIndex) {
            return false;
        }
    };
    
    // Create a JTable based on the same model as table1 but allows edits
    JTable table2 = new JTable(table1.getModel());
    
    // Create a model that disallows edits; JTable's using this model will not allow edits
    TableModel model = new DefaultTableModel() {
        public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
        }
    };

⌨️ 快捷键说明

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