Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Urgent Pls Help - Painting

 
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
 
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


 
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.


 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic