Monday 15 February 2010

java - how to get value from ticked jcheckbox in a row from jtable -


I have 3 columns and a dynamic line based on the database value and based on this code, a jcheckbox Is:

/ P>

  tableclaim tagel = tabel .get column model (). GetColumn (2); Tcolumn.setCellRenderer (tabel.getDefaultRenderer (Boolean.class)); Tcolumn.setCellEditor (tabel.getDefaultEditor (Boolean.class));   

Example of My Table:

  ======================== =================== val 1 || Val 2 || Val 3 (checkbox) || =========================================== FB || DB || With || Checkbox || DB || With || DB || With || Checkbox || ===========================================   

My question is simple, how can I get 1 value from the check box in column 2 (value 3)?

I tried many simple codes but still got an error.

This is my code:

 for  (int row = 0; line & lt; = desktail.Set selected number (), line ++) {boolean B = (Boolean) TBLModel.Jet Valueate (line, 2)); If (b.booleanvalue ()) {System.out.print (tblModel.getValueAt (line, 0) + "||"); }}    

It is not clear what error you get or where you are Meets; I suspect that casting an error at Boolean is a JCheckbox for the Boolean.class as a general guide; You should not set it explicitly. As shown, make sure that you follow the following principles to make your artist successful:

  • Boolean in your TableModel .class / code>.

  • Return code getColumnClass () for code related to Boolean.class .

  • Return the desired value from isCellEditable () .

No comments:

Post a Comment