Problem with CheckBox in JTable - Java

1

I want to solve a small problem that I have about a project in java and it is that I have a checkbox in a table but he only shows me the value true or false, I want him to show me his corresponding checkbox someone knows how I can solve it.

while (rs.next()) {
                Object[] filas = new Object[CantidadColumnas];
                filas[0] = rs.getObject(1);
                filas[1] = rs.getObject(2);
                filas[2] = rs.getObject(3);
                filas[3] = formato0d.format(rs.getObject(4));
                filas[4] = rs.getObject(5);
                filas[5] = formato2d.format(rs.getObject(6));
                JCheckBox checkbox = new checkBoxPrueba();
                if (rs.getBoolean(7)){
                    checkbox.setSelected(true);
                }else{
                    checkbox.setSelected(false);
                }
                filas[6] = checkbox;
                //filas[6] = new JCheckBox().setSelected(true);
                modelo1.addRow(filas);
            }
    
asked by Sebastian Salazar 01.02.2018 в 16:46
source

1 answer

1

To add the checkBox to a jTable getColumn(6) you can change it by the number of your column, this you can put it where you create the jTable

TableColumn tc = tblDetail.getColumnModel().getColumn(6);
tc.setCellEditor(tblDetail.getDefaultEditor(Boolean.class));
tc.setCellRenderer(tblDetail.getDefaultRenderer(Boolean.class));
    
answered by 01.02.2018 / 17:14
source