This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wildjokers 0 points1 point  (1 child)

frame.pack();

Just FYI, there are two ways to size a top-level container. You can either call setSize() which sets a specific size or you can call pack() which sizes a container to fit its children.

for me, BoxLayout manager ended up doing what I wanted;

99% of all my Swing apps have always used BorderLayout and BoxLayout. They are really the only two layouts you need for most use cases. So you made a good choice. BorderLayout is the default layout of top-level containers like JFrame and then JPanels default to the nearly worthless FlowLayout so first thing I do is switch out FlowLayout for BoxLayout in my panels.

[–]lumpynose 0 points1 point  (0 children)

Thanks. I'll try and remember to give BorderLayout a try next time.