This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - editing Objects

 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a table. It has a column that contains an object. It has a custom renderer that displays the field name of the object. I'd like to be able to edit this name, but whenever I try to hook it up for editing it always tries to edit the object.
Does anyone have any ideas?
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use DefaultTableModel, you can override the setValueAt method and do what you want.
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll give that a try (I didn't think of that trying that one). Also, while I was looking for answers I discovered I was able to override toString and get rid of my custom renderer.
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Worked great! Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic