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....
Than开发者_开发知识库k You
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.
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.
精彩评论