SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
JAVA
Layout Manager
Prepared by
Miss. Arati A. Gadgil
LayoutManagers
The LayoutManagers are used to arrange components in
a particular manner.
 LayoutManager is an interface that is implemented by
all the classes of layout managers.
A layout manager is an object that controls the size and
the position of components in a container.
Every Container object has a LayoutManager object that
controls its layout.
2
There are following classes that represents the
layout managers:
java.awt.BorderLayout
java.awt.FlowLayout
java.awt.GridLayout
java.awt.CardLayout
java.awt.GridBagLayout
javax.swing.BoxLayout
javax.swing.GroupLayout
javax.swing.ScrollPaneLayout
javax.swing.SpringLayout etc.
3
BorderLayout:
The BorderLayout is used to arrange the components in five
regions: north, south, east, west and center.
Each region (area) may contain one component only. It is
the default layout of frame or window.
The BorderLayout provides five constants for each region:
public static final int NORTH
public static final int SOUTH
public static final int EAST
public static final int WEST
public static final int CENTER
4
Example of BorderLayout class:
Constructors of BorderLayout class:
BorderLayout(): creates a border
layout but with no gaps between the
components.
BorderLayout(int hgap, int vgap):
creates a border layout with the given
horizontal and vertical gaps between the
components.
5
GridLayout
The GridLayout is used to arrange the components in rectangular
grid. One component is displayed in each rectangle.
Constructors of GridLayout class:
1.GridLayout(): creates a grid layout with one column per
component in a row.
2.GridLayout(int rows, int columns): creates a grid layout with
the given rows and columns but no gaps between the components.
3.GridLayout(int rows, int columns, int hgap, int vgap):
creates a grid layout with the given rows and columns alongwith
given horizontal and vertical gaps.
6
GridLayout
7
FlowLayout
The FlowLayout is used to arrange the components in a
line, one after another (in a flow). It is the default layout
of applet or panel.
Fields of FlowLayout class:
1.public static final int LEFT
2.public static final int RIGHT
3.public static final int CENTER
4.public static final int LEADING
5.public static final int TRAILING
8
Constructors of FlowLayout class:
1.FlowLayout(): creates a flow layout with centered
alignment and a default 5 unit horizontal and vertical
gap.
2.FlowLayout(int align): creates a flow layout with the
given alignment and a default 5 unit horizontal and
vertical gap.
3.FlowLayout(int align, int hgap, int vgap):
creates a flow layout with the given alignment and the
given horizontal and vertical gap.
9
FlowLayout
10
11
CardLayout class
The CardLayout class manages the components in such a manner that
only one component is visible at a time. It treats each component as a
card that is why it is known as CardLayout.
Constructors
CardLayout(): creates a card layout with zero horizontal and vertical
gap.
CardLayout(int hgap, int vgap): creates a card layout with the given
horizontal and vertical gap.
12
methods
public void next(Container parent): is used to flip to the next card of the
given container.
public void previous(Container parent): is used to flip to the previous
card of the given container.
public void first(Container parent): is used to flip to the first card of the
given container.
public void last(Container parent): is used to flip to the last card of the
given container.
public void show(Container parent, String name): is used to flip to the
specified card with the given name.
13
BoxLayout class
Fields of BoxLayout class:
public static final int X_AXIS
public static final int Y_AXIS
public static final int LINE_AXIS
public static final int PAGE_AXIS
Constructor of BoxLayout class:
BoxLayout(Container c, int axis):
creates a box layout that arranges the components with the given axis.
Thank You
14

More Related Content

What's hot (20)

PDF
Applets
Prabhakaran V M
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Inheritance in java
RahulAnanda1
 
PPTX
Interface in java
PhD Research Scholar
 
PPTX
Java awt (abstract window toolkit)
Elizabeth alexander
 
PPTX
JAVA AWT
shanmuga rajan
 
PDF
Java threads
Prabhakaran V M
 
PPTX
Method overloading
Lovely Professional University
 
PPT
Final keyword in java
Lovely Professional University
 
PPS
Java rmi
kamal kotecha
 
PPTX
I/O Streams
Ravi Chythanya
 
PPTX
Basics of Object Oriented Programming in Python
Sujith Kumar
 
PPT
Chapter 4 data link layer
Naiyan Noor
 
PPTX
Java swing
Apurbo Datta
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
java interface and packages
VINOTH R
 
PPTX
Multithreading in java
Monika Mishra
 
PPTX
Arrays in Java
Abhilash Nair
 
PDF
Java I/o streams
Hamid Ghorbani
 
Arrays in Java
Naz Abdalla
 
Inheritance in java
RahulAnanda1
 
Interface in java
PhD Research Scholar
 
Java awt (abstract window toolkit)
Elizabeth alexander
 
JAVA AWT
shanmuga rajan
 
Java threads
Prabhakaran V M
 
Method overloading
Lovely Professional University
 
Final keyword in java
Lovely Professional University
 
Java rmi
kamal kotecha
 
I/O Streams
Ravi Chythanya
 
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Chapter 4 data link layer
Naiyan Noor
 
Java swing
Apurbo Datta
 
Classes, objects in JAVA
Abhilash Nair
 
java interface and packages
VINOTH R
 
Multithreading in java
Monika Mishra
 
Arrays in Java
Abhilash Nair
 
Java I/o streams
Hamid Ghorbani
 

Viewers also liked (9)

PPTX
Java
Anand Grewal
 
PDF
Layouts - Java
njca01
 
PDF
Java Thread Synchronization
Benj Del Mundo
 
ODP
Multithreading In Java
parag
 
PPT
GUI Programming In Java
yht4ever
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPS
Java Exception handling
kamal kotecha
 
PPT
Android ppt
blogger at indiandswad
 
Layouts - Java
njca01
 
Java Thread Synchronization
Benj Del Mundo
 
Multithreading In Java
parag
 
GUI Programming In Java
yht4ever
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
Java Exception handling
kamal kotecha
 
Ad

Similar to Java layoutmanager (20)

PPTX
LAYOUT.pptx
aparna14patil
 
PPTX
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
abhishekmathuroffici
 
PPT
Understanding layout managers
Nuha Noor
 
PPTX
Advanced Java programming
PriyadharshiniVS
 
PPT
Layout managementand event handling
Charli Patel
 
PPTX
Java card and flow layout
shiprashakya2
 
PPT
Graphical User Interface in JAVA
suraj pandey
 
PPT
Java AWR LayoutManagers for B. Tech. 2nd Year.ppt
kmd198809
 
PPT
Javalayout
Ranjeet Bhalshankar
 
PPTX
LayoutManager_Lec1.pptx
SarthakSrivastava70
 
PDF
Module 2
Tuan Ngo
 
PPTX
HASHIR_PPT about java coding which is frontend section.pptx
muhammadumairsoftwar
 
PDF
8layout Managers
Adil Jafri
 
DOCX
Java gives us layout managers whose responsibility it is to determine.docx
olsenlinnea427
 
PPTX
Advanced Java programming
vanmathy1
 
PPTX
Chapter 11.3
sotlsoc
 
PPT
Chap1 1 4
Hemo Chella
 
PPT
Chap1 1.4
Hemo Chella
 
PPTX
ADVANCED JAVA PROGRAMME
RRamyaDevi
 
PPTX
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
LAYOUT.pptx
aparna14patil
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
abhishekmathuroffici
 
Understanding layout managers
Nuha Noor
 
Advanced Java programming
PriyadharshiniVS
 
Layout managementand event handling
Charli Patel
 
Java card and flow layout
shiprashakya2
 
Graphical User Interface in JAVA
suraj pandey
 
Java AWR LayoutManagers for B. Tech. 2nd Year.ppt
kmd198809
 
LayoutManager_Lec1.pptx
SarthakSrivastava70
 
Module 2
Tuan Ngo
 
HASHIR_PPT about java coding which is frontend section.pptx
muhammadumairsoftwar
 
8layout Managers
Adil Jafri
 
Java gives us layout managers whose responsibility it is to determine.docx
olsenlinnea427
 
Advanced Java programming
vanmathy1
 
Chapter 11.3
sotlsoc
 
Chap1 1 4
Hemo Chella
 
Chap1 1.4
Hemo Chella
 
ADVANCED JAVA PROGRAMME
RRamyaDevi
 
Abstract Window Toolkit_Event Handling_python
jasminebeulahg
 
Ad

More from Arati Gadgil (16)

PPT
Java adapter
Arati Gadgil
 
PPT
Java swing
Arati Gadgil
 
PPT
Java applet
Arati Gadgil
 
PPT
Java awt
Arati Gadgil
 
PPT
Java stream
Arati Gadgil
 
PPT
Java thread
Arati Gadgil
 
PPT
Java networking
Arati Gadgil
 
PPT
Java jdbc
Arati Gadgil
 
PPT
Java package
Arati Gadgil
 
PPT
Java interface
Arati Gadgil
 
PPT
Java inheritance
Arati Gadgil
 
PPT
Java eventhandling
Arati Gadgil
 
PPT
Java exception
Arati Gadgil
 
PPT
Java collection
Arati Gadgil
 
PPT
Java class
Arati Gadgil
 
PPT
Java basic
Arati Gadgil
 
Java adapter
Arati Gadgil
 
Java swing
Arati Gadgil
 
Java applet
Arati Gadgil
 
Java awt
Arati Gadgil
 
Java stream
Arati Gadgil
 
Java thread
Arati Gadgil
 
Java networking
Arati Gadgil
 
Java jdbc
Arati Gadgil
 
Java package
Arati Gadgil
 
Java interface
Arati Gadgil
 
Java inheritance
Arati Gadgil
 
Java eventhandling
Arati Gadgil
 
Java exception
Arati Gadgil
 
Java collection
Arati Gadgil
 
Java class
Arati Gadgil
 
Java basic
Arati Gadgil
 

Recently uploaded (20)

PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
epi editorial commitee meeting presentation
MIPLM
 
infertility, types,causes, impact, and management
Ritu480198
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Horarios de distribución de agua en julio
pegazohn1978
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 

Java layoutmanager

  • 2. LayoutManagers The LayoutManagers are used to arrange components in a particular manner.  LayoutManager is an interface that is implemented by all the classes of layout managers. A layout manager is an object that controls the size and the position of components in a container. Every Container object has a LayoutManager object that controls its layout. 2
  • 3. There are following classes that represents the layout managers: java.awt.BorderLayout java.awt.FlowLayout java.awt.GridLayout java.awt.CardLayout java.awt.GridBagLayout javax.swing.BoxLayout javax.swing.GroupLayout javax.swing.ScrollPaneLayout javax.swing.SpringLayout etc. 3
  • 4. BorderLayout: The BorderLayout is used to arrange the components in five regions: north, south, east, west and center. Each region (area) may contain one component only. It is the default layout of frame or window. The BorderLayout provides five constants for each region: public static final int NORTH public static final int SOUTH public static final int EAST public static final int WEST public static final int CENTER 4
  • 5. Example of BorderLayout class: Constructors of BorderLayout class: BorderLayout(): creates a border layout but with no gaps between the components. BorderLayout(int hgap, int vgap): creates a border layout with the given horizontal and vertical gaps between the components. 5
  • 6. GridLayout The GridLayout is used to arrange the components in rectangular grid. One component is displayed in each rectangle. Constructors of GridLayout class: 1.GridLayout(): creates a grid layout with one column per component in a row. 2.GridLayout(int rows, int columns): creates a grid layout with the given rows and columns but no gaps between the components. 3.GridLayout(int rows, int columns, int hgap, int vgap): creates a grid layout with the given rows and columns alongwith given horizontal and vertical gaps. 6
  • 8. FlowLayout The FlowLayout is used to arrange the components in a line, one after another (in a flow). It is the default layout of applet or panel. Fields of FlowLayout class: 1.public static final int LEFT 2.public static final int RIGHT 3.public static final int CENTER 4.public static final int LEADING 5.public static final int TRAILING 8
  • 9. Constructors of FlowLayout class: 1.FlowLayout(): creates a flow layout with centered alignment and a default 5 unit horizontal and vertical gap. 2.FlowLayout(int align): creates a flow layout with the given alignment and a default 5 unit horizontal and vertical gap. 3.FlowLayout(int align, int hgap, int vgap): creates a flow layout with the given alignment and the given horizontal and vertical gap. 9
  • 11. 11 CardLayout class The CardLayout class manages the components in such a manner that only one component is visible at a time. It treats each component as a card that is why it is known as CardLayout. Constructors CardLayout(): creates a card layout with zero horizontal and vertical gap. CardLayout(int hgap, int vgap): creates a card layout with the given horizontal and vertical gap.
  • 12. 12 methods public void next(Container parent): is used to flip to the next card of the given container. public void previous(Container parent): is used to flip to the previous card of the given container. public void first(Container parent): is used to flip to the first card of the given container. public void last(Container parent): is used to flip to the last card of the given container. public void show(Container parent, String name): is used to flip to the specified card with the given name.
  • 13. 13 BoxLayout class Fields of BoxLayout class: public static final int X_AXIS public static final int Y_AXIS public static final int LINE_AXIS public static final int PAGE_AXIS Constructor of BoxLayout class: BoxLayout(Container c, int axis): creates a box layout that arranges the components with the given axis.