Change data in jTable
1 posts in topic
Flat View  Flat View

Posted By:   Warren_Wang
Posted On:   Thursday, May 10, 2007 02:28 PM

I need to change data in a jtable using default table model.
But the following piece of code just doesn't change the table content. The j table is contained in a scroll panel. Can someone point me to the right direction to debug the problem? Thanks,

Object[][] newTableData = { {"5","6","7","8"}, {"AA", "BB", "CC", "DD"} };
String[] ColumnHeaders = {"Title", "Rating", "Date", "Genre"};
jTableMovies = new JTable(newTableData, ColumnHeaders);

Re: Change data in jTable

Posted By:   Robert_Lybarger  
Posted On:   Thursday, May 10, 2007 06:34 PM

once you have a table model, you need to call some method in that class to set a new object/value at a given row/column, and then usually call something like "fireTableDataChanged()" to signal that the view needs to update itself ... this is probably what you are missing. You do *not* reinstantiate the jtable object. (the mind boggles to understand why you'd think that would be the right thing, but then I was new once, too.)
About | Sitemap | Contact