Professional Documents
Culture Documents
constructors of gridbaglayout
Containers which uses Border Layout as their default are: window, Frame and Dialog
classes.
Every container, by default, has a layout manager. For Panels, including Applets,
the default layout manager belongs to the class FlowLayout. For Windows, the
default layout manager is a BorderLayout. You can change the layout manager of a
container using its setLayout(LayoutManager) method
For a java.applet.Applet, the default layout manager is FlowLayout. For the content
pane of a javax.swing.JApplet, the default layout manager is a BorderLayout
Every component has a set of insets. Insets specify the widths of the component's
margins. Insets include:
top inset
left inset
bottom inset
right inset
For example, a frame's insets include a top inset that compensates for the frame's
titlebar, and insets all around that compensate for the border (which we can use to
resize the frame).
A panel contained within a frame has its own insets. Indeed, any component has its
own insets.
Layout managers are supposed to respect a container's insets and never lay out a
component in the inset margins. The layout managers supplied with the JDK all
respect this. If you write a layout manager, you should write it to respect
insets, too.
// insets (top, left, bottom, right).
public Insets getInsets()
{
return new Insets(5, 10, 15, 20);
}