Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

savings changes made in JTable

 
Kate Zoy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable made with a custom made TableModel called MyAbstractTableModel. As far as the action handling goes, this is my code:
table.getModel().addTableModelListener( new TableModelListener(){
public void tableChanged( TableModelEvent tme )
{
int col = tme.getColumn();
int row = tme.getFirstRow();
TableModel model = (TableModel)tme.getSource();
String columnName = model.getColumnName( col );
Object data = model.getValueAt( row, col );
}
this all works fine. Although, when I later go and try to get a value from my table, the change is not internally there. So I figured that after
Object data = model.getValueAt( row, col );
I needed to add another line table.setValueAt( data, row, col );
but that gives me a stackOverFlow. What can I do so that later on in my code , I can do table.getValue( someRow, someCol ); to actually return something. Right now, with the code above, the actual table is never changed (although it looks changed in the GUI) and when i do getValueAt, it returns an empty string.
I'm sorry if this is kind of confusing... it's hard to explain!
Thank you so much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic