Previous | Next | Trail Map | Creating a User Interface (with Swing) | Laying Out Components within a Container

Common Layout Problems (and Their Solutions)

Problem: How do I specify a component's exact size?

Note: All component sizes are subject to layout manager approval. The FlowLayout and GridBagLayout layout managers use the component's natural size (the latter depending on the constraints that you set), but BorderLayout and GridLayout usually don't. Other options are writing or finding a custom layout manager or using absolute positioning.
Problem: How do I resize a component? Problem: My custom component is being sized too small.

If you don't see your problem in this list, see Common Component Problems(in the Creating a User Interface trail).


Previous | Next | Trail Map | Creating a User Interface (with Swing) | Laying Out Components within a Container