Screen components on a user interface may arranged in various ways for instance they can be horizontally arranged in a serial fashion or arranged in a grid like manager. Each of these screen would be refer to as the layout of components. To manage these layout we need to have layout Manager. The abstract window toolkit (AWT) provide a group of classes known as layout Manager or Layout. A layout Manager automatically write in a container.
Types of Layouts- The various layout available in java are as follows-
(a)- Flow Layout
(b)- Border Layout
(c)- Grid Layout
(d)- GridBag Layout
(e)- Card Layout
How to set Layout- when a component is first created, it uses its default layout Manager. For example the default layout of an applet is flow layout. A new layout Manager can be set using the method SetLayout ().
(a)- Flow Layout Manager- The FlowLayout it's default layout Manager of the Applets and Panels. The components are arranged seriously from the upper left corner when there are a number of components they are arranged Row wise and left to right.
(b)- Grid Layout Manager- Grid layout help us to the container Area in a rectangular Grid. The components are Rows and coloums. This layout is used when all layout is the same size.
(c)- GridBag Layout Manager- In this layout the components need not to be of the same size. It is similar to the grid layout Manager. since the components are arranged in a grid of rows and columns. However the order of placing the components is not left to right and Top to Bottom. A container can be given the grid layout using the following-
GridBag Layout gb=new GridBag Layout ();
to use this layout information must be provided on the size and layout of each components. The class GridBag Layout contains all the information required by the class GridBag Layout to position and size of each components. The GridBag constant class can be thought of a helper class to GridBag Layout.
(d)- Card Layout Manager- The Card Layout stores a stack of several layout each layout is like a card in a Deck. The card is usually a panel object. The card to be displayed on the talk is controlled by a separate component such as a button. This layout is used when ever we need number of panel catch with a different layout to be displayed one by one. A different layout is set for each panel.
No comments:
Post a Comment