• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to prevent AWT component flicker?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My main Frame has two Panels added to it. Each of the Panels contain various components and custom components. Question is: how can I make it so the two Panels are added to the Frame (or are made visible) only after each of the Panels' components are fully rendered. I just need new screens to be shown cleanly, without flickering! (Am using JDK1.1) Thanks in advance, James
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


how can I make it so the two Panels are added to the Frame (or are made visible) only after each of the Panels' components are fully rendered.



Add them to the panel before you call setVisible(true) on the Frame...

If this problem is related to animation on components, though - you may want to google 'AWT "double buffering"'.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nate,

Thanks for the reply. I can't call setVisible(false) on the Frame, cos it must be showing all the time.

Instead, I have tried this:
1. doing panel.setVisible(false)
2. adding the components, etc. to panel
3. doing panel.setVisible(true)
4. adding panel to the Frame

...but panel does not show on the Frame (despite panel.isVisible() returning true). Any idea what the problem is?

Thank you,
James
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either:-
  • Don't call setVisible(true) until after you have added every component, OR,
  • put a validate(); statement as the last line of the constructor when you have added all components.
  • CR
     
    reply
      Bookmark Topic Watch Topic
    • New Topic