• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with refreshing AbstractTableModel window.

 
Rushan Tugushev
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm developing my first program, and run into the following problem: My program gets data from the database, then converts them into a table to display on the screen. After that, I set up a table auto-update (to update after making changes). However, I found a small bug: For example, after I delete records from a table, the table looks like this:



As you can see, white space remains free.

and

If the program does not do any action (when all space is filled with rows) and try to add a string, they do not appear as gray space hiding added rows.



What should I do to fix the bug ? To display the table I use a class that extends AbstractTableModel.

----------

here's the code ob my Table:


 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you change data in the model you need to invoke the appropriate fireXXX(...) method to tell the table to repaint itself.

Look at the AbstractTableModel to find the appropriate method for you to invoke.
 
Rushan Tugushev
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added fireTableStructureChanged() into the code, that refresh the table - everething works !!!
Thank you a lot !!!
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think my suggestion wasn't clear. The fireXXX(...) method should be invoked within the TableModel itself, not the application code that updates the TableModel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!