Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Urgent Pls Help - Painting

 
Garry Kalra
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!