Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Changing Panel without flicker

Posted on 1999-07-16
Medium Priority
Last Modified: 2010-04-16
I have Option panel based on the selection on this panel,
I need to change the right panel based on the selection made by user. I doing this by removeing current Panel and adding the new code:  Panel.remove(currPanel); Panel.add(newPanel) and after that I am issuing panel.repaint() and panel.validate() as panel.repaint() is not showing the current panel, but validate works but the "Problems is it Flickers a lot".

Please suggeest is there is any better method of doing

Thank u verymuch
Question by:shanthipower
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 1246290
If I understand the situation I would use a CardLayout manager.
That way you can flip between the two without having to create a whole new panel each time a user makes a choice.  There is alot of overhead in destroying and then creating new panels.  It is much easier and faster to keep the same panels and changing the relevent components on the panels.
I dont know a whole lot about the project but that is my take with the info I have.
repaint() simply paints the layout that the component thinks it has already (does not relayout the components (no layout calculations))
validate() goes through the layout process (calculations are made as to where children should appear)
if you are adding/subtracting components validate is the correct choice.
LVL 16

Expert Comment

ID: 1246291
CardLayout will do everything for you.

LVL 16

Expert Comment

ID: 1246292
conick, post an answer.

Accepted Solution

conick earned 200 total points
ID: 2018524

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question