Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make an editor for a boolean JTable column

 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the process of making an attendance application. Right now, I'm working on building the table that will hold the students and allow the user to mark students as absent/present.
The compilable and runnable code below displays my current JTable. It looks how I want it to, but I'm uncertain about how to make the check boxes selectable and also how to gather the check boxes' boolean values. I've read the Java tutorial on this matter, but I didn't really understand it. Can someone explain it to me simply?
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind, all I had to do was override the method isEditable().
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. your AbstractTableModel missing to override two important methods, otherwise isnt possible to change true to false,

- isCellEditable(otherwise editor isnt allowed)

- setValueAt(otherwise value isnt stored to theAbstractTableModel)

2. Id be suggest to starting with DefaultTableModel, then transfom required override to the AbstractTableModel


3. for your idea and code structure isnt required to use AbstractTableModel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic