Java Swing display problem
I wr开发者_C百科ote a gui program in SWING but i have a strange problem. I have a frame, a panel, a menu and the components. I put all the components in the panel and then i add this and the menu to the frame.
When I run the program it shows up only a window with the menu but if i maximaze the window or just change a little the dimesions of the window while it's running all the components shows up!
Is this a bug or something?
Can't repeat it often enough: Do use a LayoutManager!
What you're probably seeing is that components have not been laid out by your layout manager at first, which only happens when the frame is resized.
I suspect you will want to call frame.pack() after adding your components.....
精彩评论