Jeetesh Nataraj
Jeetesh Nataraj

Reputation: 608

Delay of Display of JComponents inside JDialog?

Whenever I make small changes to JComponents either in size or alignment, when tried to display

--> An empty dialog frame is displayed, when I try to enlarge the size of JDialog with the mouse the Components are Displayed...

-->So I disable the setResize() property...

-->still no effect...

Help me on this....

Thank You

Upvotes: 0

Views: 346

Answers (2)

Denis Tulskiy
Denis Tulskiy

Reputation: 19177

There are several things that can cause this:

Something's wrong with the layout managers you use: try calling revalidate() and repaint() on the content pane after you change your components. And make sure you make changes to all the components in the Swing Event Dispatch thread. You can do so by calling SwingUtitlites.invokeLater().

If you're on a linux box with compiz on, java sometimes fails to redraw the frame. It's an old bug only partially fixed. Try to use metacity and see if you can reproduce the problem.

Upvotes: 1

camickr
camickr

Reputation: 324147

I'm guessing your code looks something like this:

dialog.pack();
dialog.setVisible( true );
dialog.add( someComponent );

The code should be:

dialog.add( someComponent );
dialog.pack();
dialog.setVisible( true );

That is you need to add the components to the dialog BEFORE you make it visible.

Upvotes: 1

Related Questions