Java: Layouts

Layouts tell Java where to put components in containers (JPanel, content pane, etc). Every panel (and other containers) has a default layout, but it's better to set the layout explicitly for clarity.

Create a new layout object (using one of its constructors) and use the container's setLayout method to set the layout. Each layout has its own way to resize components to fit the layout, and you must become familiar with these.

General advice

.

More notes