Core Java

Debasish Pratihari

LayoutManager :


LayoutManager determines the way components
will be arranged inside the container.



All container’s have their default LayoutManger.



However You can apply a different
LayoutManager to the containers if required.



LayoutManager Classes are Provided in
java.awt and javax.swing package.

FlowLayoutManager :


FlowLayout Manager lays down the components
in a row and automatically spills components
onto the next row if row is full.



The default positing of the components is
centered in the container, and the default
orientation is from left to right.



Constants to Control FlowLayoutManager:
o LEFT
o RIGHT
o CENTER
o LEADING
TRAILING



Examples:


FlowLayout f= new FlowLayout();



FlowLayout f= new
FlowLayout(FlowLayout.LEFT);



FlowLayout f= new
FlowLayout(FlowLayout.LEFT,10,20);

Lecture/core/awt4/16

Page #1

feel the Technology…
Core Java

Debasish Pratihari

BorderLayoutManager:


The BorderLayoutManager divides the container
into file regions like
o EAST
o WEST
o NORTH
o SOUTH
o CENTER.



Each region can accommodate only one
component.

Example :
import java.awt.*;
class BorderTest extends Frame{
Button b1,b2,b3,b4,b5;
BorderTest(){
b1= new Button("EAST");
b2= new Button("WEST");
b3= new Button("NORTH");
b4= new Button("SOUTH");
b5=new Button("CENTER");
add(b1, BorderLayout.EAST);
add(b2,BorderLayout.WEST);
add(b3,BorderLayout.NORTH);
add(b4,BorderLayout.SOUTH);
add(b5,BorderLayout.CENTER);
setTitle("BorderDemo By Debasish Pratihari");
setSize(200,200);
setVisible(true);
}
public static void main(String args[]){
new BorderTest();
}
}

Lecture/core/awt4/16

Page #2

feel the Technology…
Core Java

Debasish Pratihari

CardLayout:


The CardLayout manager arrange the
components in a stack, one on the top of
another.



The first component will be at the top, so will be
the only visible component.



Methods to operate CardLayout
o void previous(Container parent)
o void first (Container parent)
o void last(Container parent)
o void show(Container parent)

Example :
import java.awt.*;
import java.awt.event.*;
class CardTest extends Frame implements ActionListener{
Button b1,b2,b3,b4,b5;
CardLayout card;
CardTest(){
b1= new Button("JAVA");
b2= new Button("J2EE");
b3= new Button("C");
b4= new Button("C++");
b5=new Button("ORACLE");
card= new CardLayout(20,50);
setLayout(card);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
add(b1,"card
add(b2,"card
add(b3,"card
add(b4,"card
add(b5,"card

1");
2");
3");
4");
5");

setTitle("BorderDemo By Debasish Pratihari");
setSize(200,200);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
card.next(this);
}
}
public static void main(String args[]){
new CardTest();
}
}
Lecture/core/awt4/16

Page #3

feel the Technology…
Core Java

Debasish Pratihari

GridLayout:
 A GridLayout manager arranges components in
a rectangular grid within a container.
Constructors:


GridLayout()



GridLayout(int rows, int cols)



GridLayout(int
vgaps)

rows,int

cols,

int

hgaps,

int

Example :
import java.awt.*;
25%

Note :

class GridTest extends Frame {
GridTest(){
GridLayout layout= new GridLayout(3,3,10,10);
setLayout(layout);
for(int i=1;i<=9;i++)
add(new Button("Button "+i));

If you want the window
to assume the size that
just accommodates the
component it contains,
use pack()

setTitle("GridDemo By Debasish Pratihari");
setVisible(true);
pack();
}
public static void main(String ar[]){
new GridTest();
}
}

Output :

Lecture/core/awt4/16

Page #4

feel the Technology…

More Related Content

PPTX
Relational Database Management System
DOC
Ficha de Dados Pessoais 2010 6º ano
PPT
Fip lezing Istanbul deel 2
PDF
Hva Lezing
PDF
PyCon 2011 Scaling Disqus
ODT
Guia de blogger
PPTX
设计资料总结
KEY
Lecture somerset webversie
Relational Database Management System
Ficha de Dados Pessoais 2010 6º ano
Fip lezing Istanbul deel 2
Hva Lezing
PyCon 2011 Scaling Disqus
Guia de blogger
设计资料总结
Lecture somerset webversie

Viewers also liked (20)

PDF
Lecture 18
PDF
Javaday 2009 php e java
PDF
Confsl 2010 Facebook Framework
PDF
090613 Ideo
PPT
Bolji svet - Uvodni webinar
PDF
I premios bermejos diplomas
PPT
Routines
PPT
Divosa v1.3
PPTX
The Mighty Gabby Embodying Resistance in the Creative Process
PPTX
技术培训
PPT
Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...
PPT
Jane's walk 2012 evolution of ottawa
PPT
Rob Whiteman - Learning Pool Conference
PPT
Colin Paton
PDF
Design Challenge | Pelephone Corporate Website
KEY
Aag presentatie 3 februari
KEY
Pondres Social Marketing Event preso's
PPTX
Jammy Create presentation
PDF
Lezing TNT
PDF
The Public Sector Learning Community
Lecture 18
Javaday 2009 php e java
Confsl 2010 Facebook Framework
090613 Ideo
Bolji svet - Uvodni webinar
I premios bermejos diplomas
Routines
Divosa v1.3
The Mighty Gabby Embodying Resistance in the Creative Process
技术培训
Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...
Jane's walk 2012 evolution of ottawa
Rob Whiteman - Learning Pool Conference
Colin Paton
Design Challenge | Pelephone Corporate Website
Aag presentatie 3 februari
Pondres Social Marketing Event preso's
Jammy Create presentation
Lezing TNT
The Public Sector Learning Community
Ad

Similar to Lecture 16 (20)

PPT
Layout managementand event handling
PPTX
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
PPT
Understanding layout managers
PPT
Java layoutmanager
PPTX
LAYOUT.pptx
DOCX
Java gives us layout managers whose responsibility it is to determine.docx
PPTX
Java card and flow layout
PPT
Graphical User Interface in JAVA
PPT
24-BuildingGUIs Complete Materials in Java.ppt
PPT
java swing
PPTX
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
PPTX
PDF
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
PPTX
AWT.pptx
PPTX
HASHIR_PPT about java coding which is frontend section.pptx
PPTX
Chapter 11.3
PPT
Chap1 1 4
PPTX
Abstract Window Toolkit_Event Handling_python
PPT
Chap1 1.4
Layout managementand event handling
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
Understanding layout managers
Java layoutmanager
LAYOUT.pptx
Java gives us layout managers whose responsibility it is to determine.docx
Java card and flow layout
Graphical User Interface in JAVA
24-BuildingGUIs Complete Materials in Java.ppt
java swing
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
AWT.pptx
HASHIR_PPT about java coding which is frontend section.pptx
Chapter 11.3
Chap1 1 4
Abstract Window Toolkit_Event Handling_python
Chap1 1.4
Ad

More from Debasish Pratihari (19)

PDF
Lecture 24
PDF
Lecture 23
PDF
Lecture 22
PDF
Lecture 21
PDF
Lecture 20
PDF
Lecture 19
PDF
Lecture 17
PDF
Lecture 14
PDF
Lecture 10
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF
PDF

Recently uploaded (20)

PDF
Five Habits of High-Impact Board Members
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPT
What is a Computer? Input Devices /output devices
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
Five Habits of High-Impact Board Members
Custom Battery Pack Design Considerations for Performance and Safety
Enhancing emotion recognition model for a student engagement use case through...
Taming the Chaos: How to Turn Unstructured Data into Decisions
Hindi spoken digit analysis for native and non-native speakers
Developing a website for English-speaking practice to English as a foreign la...
What is a Computer? Input Devices /output devices
Getting started with AI Agents and Multi-Agent Systems
CloudStack 4.21: First Look Webinar slides
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Module 1.ppt Iot fundamentals and Architecture
Flame analysis and combustion estimation using large language and vision assi...
NewMind AI Weekly Chronicles – August ’25 Week III
sbt 2.0: go big (Scala Days 2025 edition)
A contest of sentiment analysis: k-nearest neighbor versus neural network
Zenith AI: Advanced Artificial Intelligence
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
OpenACC and Open Hackathons Monthly Highlights July 2025
Final SEM Unit 1 for mit wpu at pune .pptx

Lecture 16

  • 1. Core Java Debasish Pratihari LayoutManager :  LayoutManager determines the way components will be arranged inside the container.  All container’s have their default LayoutManger.  However You can apply a different LayoutManager to the containers if required.  LayoutManager Classes are Provided in java.awt and javax.swing package. FlowLayoutManager :  FlowLayout Manager lays down the components in a row and automatically spills components onto the next row if row is full.  The default positing of the components is centered in the container, and the default orientation is from left to right.  Constants to Control FlowLayoutManager: o LEFT o RIGHT o CENTER o LEADING TRAILING  Examples:  FlowLayout f= new FlowLayout();  FlowLayout f= new FlowLayout(FlowLayout.LEFT);  FlowLayout f= new FlowLayout(FlowLayout.LEFT,10,20); Lecture/core/awt4/16 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari BorderLayoutManager:  The BorderLayoutManager divides the container into file regions like o EAST o WEST o NORTH o SOUTH o CENTER.  Each region can accommodate only one component. Example : import java.awt.*; class BorderTest extends Frame{ Button b1,b2,b3,b4,b5; BorderTest(){ b1= new Button("EAST"); b2= new Button("WEST"); b3= new Button("NORTH"); b4= new Button("SOUTH"); b5=new Button("CENTER"); add(b1, BorderLayout.EAST); add(b2,BorderLayout.WEST); add(b3,BorderLayout.NORTH); add(b4,BorderLayout.SOUTH); add(b5,BorderLayout.CENTER); setTitle("BorderDemo By Debasish Pratihari"); setSize(200,200); setVisible(true); } public static void main(String args[]){ new BorderTest(); } } Lecture/core/awt4/16 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari CardLayout:  The CardLayout manager arrange the components in a stack, one on the top of another.  The first component will be at the top, so will be the only visible component.  Methods to operate CardLayout o void previous(Container parent) o void first (Container parent) o void last(Container parent) o void show(Container parent) Example : import java.awt.*; import java.awt.event.*; class CardTest extends Frame implements ActionListener{ Button b1,b2,b3,b4,b5; CardLayout card; CardTest(){ b1= new Button("JAVA"); b2= new Button("J2EE"); b3= new Button("C"); b4= new Button("C++"); b5=new Button("ORACLE"); card= new CardLayout(20,50); setLayout(card); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); add(b1,"card add(b2,"card add(b3,"card add(b4,"card add(b5,"card 1"); 2"); 3"); 4"); 5"); setTitle("BorderDemo By Debasish Pratihari"); setSize(200,200); setVisible(true); } public void actionPerformed(ActionEvent e){ card.next(this); } } public static void main(String args[]){ new CardTest(); } } Lecture/core/awt4/16 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari GridLayout:  A GridLayout manager arranges components in a rectangular grid within a container. Constructors:  GridLayout()  GridLayout(int rows, int cols)  GridLayout(int vgaps) rows,int cols, int hgaps, int Example : import java.awt.*; 25% Note : class GridTest extends Frame { GridTest(){ GridLayout layout= new GridLayout(3,3,10,10); setLayout(layout); for(int i=1;i<=9;i++) add(new Button("Button "+i)); If you want the window to assume the size that just accommodates the component it contains, use pack() setTitle("GridDemo By Debasish Pratihari"); setVisible(true); pack(); } public static void main(String ar[]){ new GridTest(); } } Output : Lecture/core/awt4/16 Page #4 feel the Technology…