Showing posts with label FlowLayout. Show all posts
Showing posts with label FlowLayout. Show all posts

Friday, 14 March 2014

LAYOUT MANAGERS:FlowLayout

FlowLayout places component in rows from left to right. Components towards the end of row are written on next row............

FlowLayout

FlowLayout places component in rows from left to right. Components towards the end of row are written on next row, if there is not enough space in the current row. The FlowLayout honors the specified size of a component. The size of a component never changes regardless of size of container.

 constructors of FlowLayout


Typically the constructor is called in the call to the container's setLayout method (see example code). The parameterless FlowLayout() constructor is probably most common, but there are some good places to use the alignment.

  • FlowLayout();
  • FlowLayout(int alignment);
  • FlowLayout(int alignment, int hor_gap, int ver_gap);

Alignment can take values of constants - LEFT, CENTER and RIGHT. The default alignment for the components in a row is center. Default horizontal and vertical gaps are 5 pixels.


  • FlowLayout.LEFT
  • FlowLayout.CENTER
  • FlowLayout.RIGHT

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.