简体   繁体   中英

How to Disable a Certain Column in JTable

How can I use this code with my existing JTable from the GUI Editor.

    JTable table = new JTable();
    public boolean isCellEditable(int row, int column) {
        return false;
    }

Thanks a lot. Sorry I'm just newbie here.

This will disable every cell in the JTable .

JTable table = new JTable() {
    @Override
    public boolean isCellEditable(int row, int column) {                
        return false;               
    };
};

You might want to override the method isCellEditable to selectively disable a particular column, like return (column == 0) would disable the first column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM