javacodex.com
Java Examples
Java Examples
memu home questions

Layout Managers

A layout manager is an object that controls the size and the position of components in a container. Every Container object has a LayoutManager object that controls its layout.

BorderLayout
The BorderLayout divides a container’s space into five areas: north, south, east, west, and center. When you add a component to a container with a BorderLayout, you need to specify which of the five areas you want to add the component. The BorderLayout class defines five constants to identify each of the five areas. The constants are NORTH, SOUTH, EAST, WEST, and CENTER.
BoxLayout
The BoxLayout arranges components in a container either horizontally in one row or vertically in one column.
CardLayout
The CardLayout lays out components in a container as a stack of cards. Like a stack of cards, only one card (the card at the top) is visible in a CardLayout. It makes only one component visible at a time.
FlowLayout
The FlowLayout is the simplest layout manager in Swing. It lays out the components horizontally, and then vertically. It lays the components in the order they are added to the container.
GridBagLayout
The GridBagLayout lays out components in a grid of rectangular cells arranged in rows and columns similar to the GridLayout. However, it is much more powerful than the GridLayout.
GridLayout
A GridLayout arranges components in a rectangular grid of equally sized cells. Each component is placed in exactly one cell. It does not respect the preferred size of the component. It divides the available space into equally sized cells and resizes each component to the cell’s size.
GroupLayout
GroupLayout is a layout manager that was developed for GUI builders such as Matisse, the GUI builder provided with the NetBeans IDE. Although the layout manager was originally designed to suit the GUI builder needs, it also works well for manual coding.
SpringLayout
SpringLayout is a very flexible layout manager that can emulate many of the features of other layout managers. SpringLayout is, however, very low-level and as such you really should only use it with a GUI builder, rather than attempting to code a spring layout manager by hand.

Contact: javacodex@yahoo.com