File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to make an editor for a boolean JTable column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make an editor for a boolean JTable column" Watch "How to make an editor for a boolean JTable column" New topic
Author

How to make an editor for a boolean JTable column

Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 231
    
    1

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

Joined: Apr 20, 2011
Posts: 231
    
    1

Never mind, all I had to do was override the method isEditable().
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 154
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to make an editor for a boolean JTable column
 
Similar Threads
Right Align numbers in Jtable
? JTable getColumnName
JRadioButton in JTable
Reg Appending new row to already existing JTable
JCheckBox in JTable