This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes refresh JPanel containing JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "refresh JPanel containing JTable" Watch "refresh JPanel containing JTable" New topic

refresh JPanel containing JTable

jess bianco

Joined: Feb 06, 2010
Posts: 2
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

Joined: Jun 13, 2009
Posts: 2180
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

Joined: Feb 06, 2010
Posts: 2
here is my code

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270

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

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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?
Consider Paul's rocket mass heater.
subject: refresh JPanel containing JTable