Java

826 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
826
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
45
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java

  1. 1. PRESENTATION ONLAYOUT MANAGERS
  2. 2. INTRODUCTION Java uses Layout Managers to define the location and size of Graphical User Interface components. Java technology uses Layout Managers to define the location and size of Graphical User Interface components.. A Layout Manager implements a layout policy that defines constraints between components in a container.
  3. 3. TYPES OF LAYOUT MANAGERJava technology provides the following LayoutManagers, each of which implements the LayoutManager interface: Flow Layout Grid Layout Border Layout CardLayout
  4. 4. DEFAULT LAYOUT MANAGER The FlowLayout is the default Layout Manager for Panel, and hence the Applet class. The BorderLayout is the default Layout Manager for Window class and its subclasses (Frame and Dialog).
  5. 5. SETTING LAYOUT MANAGERS The following method defined in the Container class can be used for setting layout managers. void setLayout(LayoutManager mgr);
  6. 6. FLOWLAYOUT MANAGER 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.
  7. 7. CONTD…. The following constructors of FlowLayout are provided by AWT – FlowLayout(); FlowLayout(int alignment); FlowLayout(int alignment, int hor_gap, int ver_gap);
  8. 8. CONTD….
  9. 9. GRIDLAYOUT MANAGER A Grid Layout Manager places the components in a rectangular grid. Each components position is identified by a column and row. All the cells in the grid have same size and width. Each component is stretched to the cell size. So a Grid Layout ignores the Components preferred size.
  10. 10. CONTD….The GridLayout class provides the followingconstructors: GridLayout(); GridLayout(int rows, int columns); GridLayout(int rows, int columns, int hor_gap, int ver_gap);
  11. 11. CONTD….
  12. 12. BORDERLAYOUT MANAGER A BorderLayout Manager divides the window into five regions - North, East, West, South and Center. A component can be explicitly added to one of the regions using the add() method of the Container class. Any space left over by the component in North, East, South and West is occupied by the component in Center.
  13. 13. CONTD: The BorderLayout class defines the following constructors : BorderLayout(); BorderLayout(int hor_gap, int ver_gap);
  14. 14. CONTD…
  15. 15. CARD LAYOUT The CardLayout class is unique among the other layout managers in that it stores several different layouts. Each layout can be thought of as being on a separate index card in a deck that can be shuffled so that any card is on top at a given time.
  16. 16. CARD LAYOUTCardLayout provides these two constructors: CardLayout( ) CardLayout(int horz, int vert)
  17. 17. CONTD…
  18. 18. THANK YOU

×