Showing posts with label gridlayout. Show all posts
Showing posts with label gridlayout. Show all posts

Thursday, 13 March 2014

LAYOUT MANAGERS

A Layoutmanager automatically arrange your controls within a window by using some type of algorithm.Java technology uses Layout Managers to define the location and size of Graphical User Interface components.


UNDERSTANDING LAYOUT MANAGERS:



A Layoutmanager automatically arrange your controls within a window by using some type of algorithm.Java technology uses Layout Managers to define the location and size of Graphical User Interface components. Java technology does not encourage programmers to use absolute location and size of components. Java technology instead places components based on specified Layout Manager. 

          A Layout Manager implements a layout policy that defines constraints between components in a container.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.A layout manager is an object that implements the LayoutManager interface* and determines the size and position of the components within a container. Although components can provide size and alignment hints, a container's layout manager has the final say on the size and position of the components within the container.

Basic Layout Managers


  • FlowLayout:

Default for java.applet.Applet, java.awt.Panel and java.swing.JPanel. Places components sequentially (left to right) in the order they were added. You can specify the order.

Tuesday, 11 March 2014

LAYOUT MANAGERS:GridLayout

A GridLayout places components in a grid of cells


GridLayout

GridLayout lays out components in a two dimensional grid.When you instantiate a gridLayout ,you define the number of rows and columns.A GridLayout places components in a grid of cells.Each component takes all the available space within its cell.Each cell is exactly the same size.Components are added to the layout from left to right, top to bottom.

The constructers supported by the GridLayout are shown here


  • GridLayout():create a single_column grid layout
  • GridLayout(int rows, int columns):Creates a grid layout with the specified number of rows and columns.
  •  GridLayout(int rows, int columns, int horizontalGap, int verticalGap):To specify the horizontal and vertical space left between components in horzontalGap and verticalGap