How to gray-out non-editable cell in jtable?

后端 未结 3 684
Happy的楠姐
Happy的楠姐 2020-12-03 19:58

I want to gray non-editable cell in JTable. I\'m using such TableCellRenderer:

TableColumn column = table.getColumnModel().getColumn(0);
column.setCellRender         


        
3条回答
  •  一整个雨季
    2020-12-03 20:26

    Return an instance of GrayableCheckboxCellRenderer in a TableCellEditor.

    Addendum: Aesthetically, you may want to condition the renderer's and editor's colors based on the defaults provided by the current Look & Feel, for example:

    Color hilite = UIManager.getColor("Table.selectionBackground");
    

提交回复
热议问题