aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable refresh" Watch "JTable refresh" New topic
Author

JTable refresh

Yves Troch
Greenhorn

Joined: Jan 05, 2013
Posts: 4

I'm trying to get this to work, but i can't seem to do it on my own:

In my main screen of my application i have a JComboBox where a user can select a "team", underneath the combobox should be a table with all the players of the selected team.
I think the current implementation of the table is less than "clean" but it's working at the best i got it so far.
the current code gives me the players of the team, but the table gets added to the frame instead of replacing it like i want it to.

My currently used code:

for the JCombobox:


i'm creating the tablemodel in the actionlistener ong the combobox like this:
(i translated the variables for easier reading, i think i got em all...)



if someone would be willing to give me a push in the right direction, or just point out where i'm going wrong, that would be great,
Thanks.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> but the table gets added to the frame instead of replacing it like i want it to.

don't replace the table - leave it there and work with the table's model.

populate a new TableModel with the combo selection, then set that as the table's model.
Yves Troch
Greenhorn

Joined: Jan 05, 2013
Posts: 4

Thank you, that did the trick!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable refresh