Search code examples
jtablerenderjcheckbox

JCheckBox not being rendered within JTable (JRE?)


I have a Jtable and intend to add JCheckboxes to it. There is quite a clear example here which I implemented yet kept on getting "true" and "false" String values when running. I then tried to run the example itself and discovered that it too is displaying "true"/"false" string values.

enter image description here

Is this a problem with my JRE? How can I be able to view/work with checkboxes?

Thanks.


Solution

  • Did you make sure to override this function in your table model? This is what tells the table that those values are Booleans.

     @Override
     public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
     }