• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtable is not refreshing properly

 
Fred Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to this board, and I have found the postings extremely helpful. Now I have a quick question for everybody. Thanks in advance.
Everything works fine when doing "Search". The table does refresh after each search. After finishing implementing booking methods, JTable (extends AbstractTableModel) is not working properly.
The user click the flight and a dialog will pop up asking the user for number of seats. After changing the data in the database successfully, I refresh the Jtable, the data in the row that I modified is no longer being displayed. Now it is just display a blank row.
Fred
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fred ,
How do you refresh the Table ?
Do you use the fireTableDataChanged() method
of AbstractTableModel which does it all for you ?
regards
[ January 25, 2003: Message edited by: HS Thomas ]
 
Fred Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,
Thank you for replying back. Yes, I used fireTableDataChanged() method of AbstractTableModel.
Any idea what may cause the problem after modifying the database? Thank you for your help.
Fred
 
Fred Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
Please help me...
Fred
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I refresh the Jtable, the data in the row that I modified is no longer being displayed. Now it is just display a blank row.

Perhaps we could figure it out if you post your code where you send new data to the table model and refresh the JTable itself.
Eugene.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know, what I did was to create a new TableModel each time the data changed and called the setModel method of the JTable with the new instance of my DefaultTableModel called FlightTableModel.
Mark
 
Brian Blignaut
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The approach that I took was to create a model that extends AbstractTableModel. I then created methods on it called getDataList and setDataList which contain the data that model works on. This allows the data to be changed without having to create a new model. I aslo created a method called objectUpdated which takes a int representing the index in the list of the object that was updated and the new object. This method then just fires a fireTableRowsUpdated event using the passed index as the row..
Any thoughts?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic