Showing posts with label CardLayout. Show all posts
Showing posts with label CardLayout. 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:CardLayout

A CardLayout object is a layout manager for a container. It treats each component in the container as a card.......

CardLayout


A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards. The first component added to a CardLayout object is the visible component when the container is first displayed. The ordering of cards is determined by the container's own internal ordering of its component objects. CardLayout defines a set of methods that allow an application to flip through these cards sequentially, or to show a specified card. The addLayoutComponent(java.awt.Component, java.lang.Object) method can be used to associate a string identifier with a given card for fast random access.

CardLayout provides these two constructors


  • CardLayout():Creates a new card layout with gaps of size zero.
  • CardLayout(int hgap, int vgap):Creates a new card layout with the specified horizontal and vertical gaps.