I'm currently building a GUI and in the main window, i add panels in the center(BorderLayout). I have two panels and depending on a button, i display one of them. When the switch has to happen, i remove the first and display the other. But during this i am facing refresh problems. Can anybody guide what to do as i am confused about validate, invalidate, setVisible. What to use. Any help will be greatly appreciated. Garry
tmtully
Greenhorn
Joined: Jun 01, 2001
Posts: 4
posted
0
I've ran into this before, but what fixed it for me was the following: 1) remove the component from the container 2) call invalidate on the container 3) call validate on the container 4) then repaint.
Originally posted by Garry Kalra: I'm currently building a GUI and in the main window, i add panels in the center(BorderLayout). I have two panels and depending on a button, i display one of them. When the switch has to happen, i remove the first and display the other. But during this i am facing refresh problems. Can anybody guide what to do as i am confused about validate, invalidate, setVisible. What to use. Any help will be greatly appreciated. Garry
Tim Tully
Greenhorn
Joined: Sep 16, 2001
Posts: 8
posted
0
I've ran into this before, but what fixed it for me was the following: 1) remove the component from the container 2) call invalidate on the container 3) call validate on the container 4) then repaint.
Originally posted by tmtully: I've ran into this before, but what fixed it for me was the following: 1) remove the component from the container 2) call invalidate on the container 3) call validate on the container 4) then repaint.
You could also use CardLayout on a parent panel that contains the two panels you want to switch between, and just use the button to switch between 'cards'...
-Nate
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.