• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Table cells not editable

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why this isn't working, the table displays fine, I can sort the columns, I can select a cell, but I cannot change the contents inside. I can't see anything that would be turning editing off. Hopefully this is a small enough contained code to work with.


 
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please split longer lines of code next time. That way the forum layout is preserved.

Where have you implemented setValueAt? AbstractTableModel.setValueAt does nothing at all, so neither does your table model. You can try to change the values all you want in the GUI, the model ignores these changes and returns the array values you hard coded.
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:Please split longer lines of code next time. That way the forum layout is preserved.



Where is too long? 80 chars, 90?


Rob Prime wrote:Where have you implemented setValueAt? AbstractTableModel.setValueAt does nothing at all, so neither does your table model. You can try to change the values all you want in the GUI, the model ignores these changes and returns the array values you hard coded.



I understand that, what I am saying is that I can click on any cell, but I cannot change the contents, even delete. The insertion cursor will not set. I thought that I would still be able to get focus on the cell and modify the contents, but when I moved out of the cell that it would be redrawn. No?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whether a cell is editable or not is defined by the table model's isCellEditable.
Your model extends the AbstractTableModel whose isCellEditable defaults to false. Override it to return true.
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Whether a cell is editable or not is defined by the table model's isCellEditable.
Your model extends the AbstractTableModel whose isCellEditable defaults to false. Override it to return true.



Thanks, I hadn't realized it defaulted to false.
 
Rob Spoor
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Your model extends the AbstractTableModel whose isCellEditable defaults to false. Override it to return true.


Hmmm, I thought it returned true... I probably thought of DefaultTableModel.

Still, without a setValueAt that will actually change the data in the model you can try to edit the contents all you want, as soon as you try to commit (e.g. by pressing enter) you'll see the old data.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic