| Author |
Updating a JPanel after change...
|
Kate Zoy
Ranch Hand
Joined: Feb 11, 2004
Posts: 33
|
|
I have a JTable for each item in a JComboBox. The JTable related to the selected JComboBox item is put into a JPanel. Before adding it to the JPanel, I made sure to remove the previous table. My problem is that when I choose a different item in the JComboBox, the new JTable won't show until I resize the window or do something to force it to refresh. How can I get it to refresh automatically?
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8291
|
|
|
call JPanel.invalidate().
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Kate Zoy
Ranch Hand
Joined: Feb 11, 2004
Posts: 33
|
|
JPanel.invalidate() didn't seem to work, but JPanel.validate() did. Thanks. However, I'm having one more issue out of this. JPanel contains two JTables. When I call JPanel.validate(), it seems to "reload" or "repaint" the first table, but not the second. Any clue on how to do this?
|
 |
Tony Fabeets
Ranch Hand
Joined: Dec 22, 2003
Posts: 38
|
|
2 panels, one for each JTable. panel 3 holds panel1 and panel2 (both JTables) frame.setContent(panel3); .validate() panel3 would refresh both? correct me if i'm wrong on this one. not testing this in code.
|
 |
Kate Zoy
Ranch Hand
Joined: Feb 11, 2004
Posts: 33
|
|
|
Are JPanels the only way to "customize" Layouts? BorderLayout, GridLayout and FlowLayout all seem so restrictive that I am at the point of having panel over panel over panel - so on and so forth - to make my GUI arrange things in a more designed and not so boxed way?
|
 |
 |
|
|
subject: Updating a JPanel after change...
|
|
|