• Post Reply Bookmark Topic Watch Topic
  • New Topic

JCheckbox won't toggle in a JTable  RSS feed

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is unchecked, when I clicked on it, it stays as unchecked
Thanks for inspecting my code
Jack

 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure anyone will go through your code in detail - I certainly won't, unless you post a SSCCE.

Anyway, I'd suggest to have a look at the documentation of the setValueAt method of the AbstractTableModel to see what it does (and what it doesn't do). To put it another way: given your getValueAt implementation - who is responsible for changing the values it returns as a result of user editing the cell? Can the AbstractTableModel class do it?

I'm trying to show you that just by thinking about your code - about how things are supposed to happen - can help spot problems.

Also, I'd suggest to disable as much code as possible while resolving this issue (for example the mouse listener). It helps to keep things simple when resolving problems. It is not completely impossible for the mouse listener - or other code - you currently have to interfere with the table editing somehow. Not that I see any such problem, though - as I said, I didn't go into much detail there.

You might want to have another look at the examples in the JTable tutorial - there are clickable checkbox examples there.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martin,
I use setValueAt for that column, and the error goes away

Jack
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problems are (just about AbstractTableModel)

1. not an SSCCE

2. why did you ignore API for AbstractTableModel (mentioned a few times)

- public void addRow ---> fireTableRowsInserted

- public void delRow ---> fireTableRowsInserted

- or fireTableRowsUpdated

3. public void setValueAt(Object value, int row, int col) there no reason to test for column, remove if, nor to set String value to boolean class
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!