Saturday, March 13, 2010

how to put jcheckbox to table cell?

Programmer Question

Hello, I cannot put jChceckBox to jTable cell. More likely I can put checkBox to table, but when I run module with that table, the cell where should be checkBox shows text "true" or "false". The behaviors of that cell are the same like checkbox, but it shows text value instead of checkbox.



Here is the code.



DefaultTableModel dm = new DefaultTableModel();
dm.setDataVector(new Object[][]{{"dd", "Edit", "Delete"},
{"dd","Edit", "Delete"}},
new Object[]{"Include","Component", "Ekvi"});
jTable1 = new javax.swing.JTable();

jTable1.setModel(dm);


JCheckBox chBox=new JCheckBox();
jTable1.getColumn("Include").setCellEditor(new DefaultCellEditor(chBox));
jScrollPane1.setViewportView(jTable1);


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails