• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refresh JPanel containing JTable

 
jess bianco
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a Jtable which i use only for display. i.e. no listeners etc. I put it on a JPanel.
i have another class which extends JFrame and i put all the buttons there. there is also the table with the loaded values from file.
the problem is that when i change the values i have to restart the program for the values to be seen,
any help on refreshing the panel when the user clicks on refresh?
 
Rob Camick
Ranch Hand
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing your code its hard to guess what you are doing, but I will guess that your problem is that you are creating a new JTable when you are attempting to refresh the data. This is the wrong approach. The solution is to create a new TableModel and add it to the existing table. Something like:

 
jess bianco
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my code

----------------------------------------------------------------------
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jess,
Welcome to the Ranch.

In future, while posting code, please UseCodeTags
Also do check out these tips on getting the most out of the Ranch
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have a file
your program reads this file and displays the data in a JTable
you change the contents of the file, but not via your program.
you want the changes reflected in the JTable

is this correct so far?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic