Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

refresh JPanel containing JTable

 
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?
 
Rancher
Posts: 3191
29
  • 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

----------------------------------------------------------------------
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
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?
 
Paper beats rock. Scissors beats tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic