• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data refresh not happening in JTable

 
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

User can select any value from the menu and depending on the selection of choice the data in the JTable data should be refreshed.But what's happening is whatever user selects at first only that data is displayed no other selections after the first selection are getting refreshed on the JTable.I used AbstractTableModel and called the method fireTableDataChanged() but no result.

Here is the code:


Please help me.

Regards
Sudhakar
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found solution for this:

Just added this line:



And everything is working fine.

Regards
Sudhakar
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Karnati Sudhakar:
Just added this line:



And everything is working fine.



Yes, that would work, but code ugliness remains.

If you really want to instantiate a new table and scroll pane every
time actionPerformed is called, then there should be no point in
calling fireTableDataChanged or fireTableStructureChanged, since
presumably the new ones should completely replace the old ones in
the GUI.

It's better, I think, to keep the same table and scroll pane throughout.
Just update the data array and call fireTableDataChanged, like this:
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yes, that would work, but code ugliness remains.



I changed my code a lot.Below is the modified code.Thanks for your time and suggestions Brian.



Regards
Sudhakar
 
Whatever. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic