Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes savings changes made in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "savings changes made in JTable" Watch "savings changes made in JTable" New topic

savings changes made in JTable

Kate Zoy
Ranch Hand

Joined: Feb 11, 2004
Posts: 33
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!
I agree. Here's the link:
subject: savings changes made in JTable
It's not a secret anymore!