• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checkboxes with JTables

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way the documentation reads, if a Boolean value is sent to a cell. That cell automatically renders a Checkbox. I am NOT getting that.
Vector data = new Vector();
data.add(Boolean.FALSE);
data.add(clientName);
theTableModel.addRow(data);
What is the trick here?
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
I'm only going on memory here (since I'm too lazy to verify it ;-), but if you look at the code for the "JTable" class (available in the "src.jar" -- or "src.zip" -- file that comes with the J2SE SDK), you will see that the "Class" of the "JTable" column determines what renderer will be used. Therefore, the "getColumnClass()" method (in "javax.swing.table.TableModel" interface) needs to return "Boolean.class" in order to use the "JCheckBox" renderer.
Hope this helps.
Good Luck,
Avi.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic