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

JTable

 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected sirs,

I have a JTable with two columns(I am using DefaultTableModel).The rows are created dynamically. The second column is a JComboBox with some string values.
When I re-editing the first column,I get the prevous value(Using getValue()).
ie. the Table or TableModel not refresh. what is the problem ?

regards Francis
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you press Enter after editing?

Until you press Enter, the value is still just sitting in the editor and is not applied to the model. The same is true if you type into the editor and then mouse out or something...
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, I dont press enter. It is an application for a client. How to overcome this?

Thanks,
Francis
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the cell editor component is a text field, you can add a document listener to it and call stopCellEditing() on any change to the document - this updates the model every time any text changes - you'll get an update to the model for every character entered.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic