views:

18

answers:

1

I have a JFrame with about 10 components (JLabel, Combobox, Buttons, TextFields). When I start the program, sometimes it doesn't display all of them. I tried repaint in different place and problem still there Any one help me

A: 

The general order of code for creating a GUI is:

panel.add( component1 );
panel.add( component2 );
frame.add( panel );
frame.pack();
frame.setVisible( true );

That is all components should be added to the frame before the frame is made visible.

camickr
Yeah, It works. I think all of you are right. I added "pack()" and the problem has gone. :) Thanks
Steve