Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

resize jdialog without flicker effect

843805Mar 19 2006
I made a vertical tool palette with a JDialog : I have "setcontentpane" a JPanel with vertical boxlayout.

This JPanel contains other JPanels (class PaletteZone extends JPanel) that act like tool zones : they can be collapse or expand. If you want to have look of what i'm talking about, there is an image here of the palette :

http://db-maths.nuxit.net/im1.png

Here is my problem... I have a PaletteZone method used to collapse the tool zone :
public void collapse(){
        ContentVisible=false;
        ZoneTitle.title.setIcon(rightTriangle);
// component 0 is the zone title bar, component 1 an icon set (within a JPanel) :
        this.remove(1);
        JP.validate();
}
******* 1) When I use JP.validate, there is no flickering at all and the zone collapse nicely. BUT the JDialog isn't set to the good size. If you want to have a look on what you get when you clic on "Construction" :

http://db-maths.nuxit.net/im2.png

******* 2) If I use JP.pack(), of course the dialog is correctly resized and redrawn. BUT there is a flickering effect : I've made some tries on JFrames and JDialogs and I saw that a pack() call clear immediatly the background and then send a paint call : this "clear/paint" sequence makes a bad flickering effect. I have a quite recent computer (G5 and OS X), and I use java 1.4.2 so I don't think the fact that I see this flicker is caused by hardware or software...

******* 3) If I use JP.setSize(), things behave exactly like if I do a pack() call...

Do you know what I could do to avoid this flicker ? to set the size to the JDialog without this "clear/paint" sequence ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2006
Added on Mar 19 2006
0 comments
70 views