Layout Managers Javas layout managers provide a level of abstraction to automatically map your user interface on all windowing systems The ui components are placed in containers. Each container has a layout manager to arrange the ui components within the container
Layout Managers ) Java’s layout managers provide a level of abstraction to automatically map your user interface on all windowing systems. ) The UI components are placed in containers. Each container has a layout manager to arrange the UI components within the container
Kinds of layout managers F1。 WAyout g Gridlayout g Borderlayout CardLayout GridBagLayout
Kinds of Layout Managers ) FlowLayout ) GridLayout ) BorderLayout ) CardLayout ) GridBagLayout
Example 8.1 Testing the FlowLayout Manager The components are arranged in the container from left to right in the order in which they were added. when one row becomes filled a new row is started Show Flow Layout Run
Example 8.1 Testing the FlowLayout Manager The components are arranged in the container from left to right in the order in which they were added. When one row becomes filled, a new row is started. ShowFlowLayout Run
FlowLayout Constructors public FlowLayout(int align, int hGap, int vGap) Constructs a new FlowLayout with a specified alignment, horizontal gap, and vertical gap. The gaps are the distances in pixel between components public FlowLayout (int alignment) Constructs a new FlowLayout with a specified alignment and a default gap of five pixels for both horizontal and vertical public FlowLayouto Constructs a new FlowLayout with a default center alignment and a default gap of five pixels for both horizontal and vertical
FlowLayout Constructors ) public FlowLayout(int align, int hGap, int vGap) Constructs a new FlowLayout with a specified alignment, horizontal gap, and vertical gap. The gaps are the distances in pixel between components. ) public FlowLayout(int alignment) Constructs a new FlowLayout with a specified alignment and a default gap of five pixels for both horizontal and vertical. ) public FlowLayout() Constructs a new FlowLayout with a default center alignment and a default gap of five pixels for both horizontal and vertical
Example 8.2 Testing the Gridlayout manager The GridLayout manager arranges components in a grid(matrix) formation with the number of rows and columns defined by the constructor. The components are placed in the grid from left to right starting with the first row, then the second and so on Show GridLayout Run
Example 8.2 Testing the GridLayout Manager The GridLayout manager arranges components in a grid (matrix) formation with the number of rows and columns defined by the constructor. The components are placed in the grid from left to right starting with the first row, then the second, and so on. ShowGridLayout Run