SlideShare a Scribd company logo
1 of 23
1.4 USE LAYOUT1.4 USE LAYOUT
MANAGERMANAGER
 By the end of the class, student should be able to:
◦ Define the use of layout manager in AWT
◦ Use layout manager in AWT:
 FlowLayout
 GridLayout
 BorderLayout
 BoxLayout
◦ Write java program using layout manager
 The UI components are placed in
containers.
 Each container has a layout manager to
arrange the GUI components within
the container.
 FlowLayout
 GridLayout
 BorderLayout
 BoxLayout
container.setLayout(new
SpecificLayout());
container.setLayout(new
SpecificLayout());
setLayout(new SpecificLayout());setLayout(new SpecificLayout());
Set the layout manager
here
Set the layout manager
here
AWT
SWING
 Simplest and most basic layout manager
 Components arranged in container from left to
right in the order in which they were added
 When edge of container reached, continues on
next line
 Can determine the gap between components in
pixels.
 Three constant (alignment):
◦ FlowLayout.RIGHT
◦ FlowLayout.LEFT
◦ FlowLayout.CENTER
FlowLayout.CENTER
FlowLayout.RIGHT
FlowLayout.LEFT
 public FlowLayout(int align, int hGap, int vGap)
Constructs a new FlowLayout with a specified alignment,
horizontal gap and vertical gap. The gaps are the distances in
pixel between components.
 public FlowLayout(int alignment)
Constructs a new FlowLayout with a specified alignment and a
default gap of 5 pixels for both horizontal and vertical.
 public FlowLayout()
Constructs a new FlowLayout with a default center alignment
and a default gap of 5 pixels for both horizontal and vertical.
import java.awt.*;
import javax.swing.*;
public class TestFlowLayout extends JFrame
{
public TestFlowLayout()
{
super(“Create FlowLayout");
Container c = getContentPane();
c.setLayout(new FlowLayout(FlowLayout.LEFT,20,10));
for (int i=1; i<9;i++)
c.add(new Button("button "+i));
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestFlowLayout s = new TestFlowLayout();
s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
10
20
 Divides container into a grid
 Components placed in rows and columns
 All components have same width and height
◦ Added starting from top left, then from left to right
◦ When row full, continues on next row, left to right
 public GridLayout()
Construct a new GridLayout with one column
in a single row.
 public GridLayout(int rows,
int columns)
Constructs a new GridLayout with the
specified number of rows and columns.
 public GridLayout(int rows, int
columns, int hGap, int vGap)
Constructs a new GridLayout with the
specified number of rows and columns,
along with specified horizontal and vertical
gaps between components.
import java.awt.*;
import javax.swing.*;
public class TestGridLayout extends JFrame
{
public TestGridLayout()
{
super(“Create GridLayout");
Container s = getContentPane();
s.setLayout(new GridLayout(3,2,20,10));
for (int i=1; i<7;i++)
s.add(new Button("button "+i));
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestGridLayout t = new TestGridLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
 Divides the window into 5 areas:
◦ BorderLayout.NORTH - North
◦ BorderLayout. SOUTH - South
◦ BorderLayout. EAST - East
◦ BorderLayout. WEST - West
◦ BorderLayout. CENTER - Center
 public BorderLayout()
Construct a new BorderLayout without
horizontal or vertical gaps
 public BorderLayout(int hGap,
int vGap)
Constructs a new BorderLayout with the
specified horizontal and vertical gaps
between the components.
import java.awt.*;
import javax.swing.*;
public class TestBorderLayout extends JFrame
{
public TestBorderLayout()
{
super(“Create BorderLayout");
Container s = getContentPane();
s.setLayout(new BorderLayout(20,10));
Button bNorth = new Button(“North");
Button bSouth = new Button(“South");
Button bEast = new Button(“East");
Button bWest = new Button(“West");
Button bCenter = new Button(“Center");
s.add(bNorth,BorderLayout.NORTH);
s.add(bSouth,BorderLayout.SOUTH);
s.add(bEast,BorderLayout.EAST);
s.add(bWest,BorderLayout.WEST);
s.add(bCenter,BorderLayout.CENTER);
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestBorderLayout t = new TestBorderLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.*;
import javax.swing.*;
public class TestBorderLayout extends JFrame
{
public TestBorderLayout()
{
super(“Create BorderLayout");
Container s = getContentPane();
s.setLayout(new BorderLayout(20,10));
Button bNorth = new Button(“North");
Button bSouth = new Button(“South");
Button bEast = new Button(“East");
Button bWest = new Button(“West");
Button bCenter = new Button(“Center");
//s.add(bNorth,BorderLayout.NORTH);
s.add(bSouth,BorderLayout.SOUTH);
s.add(bEast,BorderLayout.EAST);
s.add(bWest,BorderLayout.WEST);
s.add(bCenter,BorderLayout.CENTER);
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestBorderLayout t = new TestBorderLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.*;
import javax.swing.*;
public class TestBorderLayout extends JFrame
{
public TestBorderLayout()
{
super(“Create BorderLayout");
Container s = getContentPane();
s.setLayout(new BorderLayout(20,10));
Button bNorth = new Button(“North");
Button bSouth = new Button(“South");
Button bEast = new Button(“East");
Button bWest = new Button(“West");
Button bCenter = new Button(“Center");
s.add(bNorth,BorderLayout.NORTH);
s.add(bSouth,BorderLayout.SOUTH);
//s.add(bEast,BorderLayout.EAST);
s.add(bWest,BorderLayout.WEST);
s.add(bCenter,BorderLayout.CENTER);
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestBorderLayout t = new TestBorderLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.*;
import javax.swing.*;
public class TestBorderLayout extends JFrame
{
public TestBorderLayout()
{
super(“Create BorderLayout");
Container s = getContentPane();
s.setLayout(new BorderLayout(20,10));
Button bNorth = new Button(“North");
Button bSouth = new Button(“South");
Button bEast = new Button(“East");
Button bWest = new Button(“West");
Button bCenter = new Button(“Center");
//s.add(bNorth,BorderLayout.NORTH);
s.add(bSouth,BorderLayout.SOUTH);
//s.add(bEast,BorderLayout.EAST);
//s.add(bWest,BorderLayout.WEST);
s.add(bCenter,BorderLayout.CENTER);
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestBorderLayout t = new TestBorderLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.*;
import javax.swing.*;
public class TestBorderLayout extends JFrame
{
public TestBorderLayout()
{
super(“Create BorderLayout");
Container s = getContentPane();
s.setLayout(new BorderLayout(20,10));
Button bNorth = new Button(“North");
Button bSouth = new Button(“South");
Button bEast = new Button(“East");
Button bWest = new Button(“West");
Button bCenter = new Button(“Center");
s.add(bNorth,BorderLayout.NORTH);
s.add(bSouth,BorderLayout.SOUTH);
s.add(bEast,BorderLayout.EAST);
s.add(bWest,BorderLayout.WEST);
//s.add(bCenter,BorderLayout.CENTER);
setSize(350,200);
setVisible(true);
}
public static void main(String[] arg)
{
TestBorderLayout t = new TestBorderLayout();
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
 A layout manager that allows multiple
components to be laid out either vertically
or horizontally.
 The value of axis can be one of the
following:
◦ BoxLayout.X_AXIS
◦ BoxLayout.Y_AXIS
◦ BoxLayout.LINE_AXIS
◦ BoxLayout.PAGE_AXIS
 4 layout manager: FlowLayout, BorderLayout,
GridLayout and BoxLayout.

More Related Content

What's hot

Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3martha leon
 
Decision CAMP 2014 - Charles Forgy - Affecting rules performance
Decision CAMP 2014 - Charles Forgy - Affecting rules performanceDecision CAMP 2014 - Charles Forgy - Affecting rules performance
Decision CAMP 2014 - Charles Forgy - Affecting rules performanceDecision CAMP
 
Sorting algos > Data Structures & Algorithums
Sorting algos  > Data Structures & AlgorithumsSorting algos  > Data Structures & Algorithums
Sorting algos > Data Structures & AlgorithumsAin-ul-Moiz Khawaja
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioningOpenSourceIndia
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In RR Programming: Numeric Functions In R
R Programming: Numeric Functions In RRsquared Academy
 
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...AAKASH KUMAR
 
Railway reservation system
Railway reservation systemRailway reservation system
Railway reservation systemPrashant Sharma
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...AAKASH KUMAR
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de basesalcon2015
 
Mobx - performance and sanity
Mobx - performance and sanityMobx - performance and sanity
Mobx - performance and sanity500Tech
 
Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity500Tech
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fulicservernoida
 

What's hot (20)

Stacks queues
Stacks queuesStacks queues
Stacks queues
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
Decision CAMP 2014 - Charles Forgy - Affecting rules performance
Decision CAMP 2014 - Charles Forgy - Affecting rules performanceDecision CAMP 2014 - Charles Forgy - Affecting rules performance
Decision CAMP 2014 - Charles Forgy - Affecting rules performance
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Property Based Testing
Property Based TestingProperty Based Testing
Property Based Testing
 
Sorting algos > Data Structures & Algorithums
Sorting algos  > Data Structures & AlgorithumsSorting algos  > Data Structures & Algorithums
Sorting algos > Data Structures & Algorithums
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioning
 
New tsql features
New tsql featuresNew tsql features
New tsql features
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In RR Programming: Numeric Functions In R
R Programming: Numeric Functions In R
 
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
 
Railway reservation system
Railway reservation systemRailway reservation system
Railway reservation system
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
Node js
Node jsNode js
Node js
 
Ngrx: Redux in angular
Ngrx: Redux in angularNgrx: Redux in angular
Ngrx: Redux in angular
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de bases
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Mobx - performance and sanity
Mobx - performance and sanityMobx - performance and sanity
Mobx - performance and sanity
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fu
 

Viewers also liked

Viewers also liked (12)

Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
 
Chap4 4 2
Chap4 4 2Chap4 4 2
Chap4 4 2
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Fp601 chapter 5 - part 2
Fp601   chapter 5 - part 2Fp601   chapter 5 - part 2
Fp601 chapter 5 - part 2
 
Fp601 chapter 6
Fp601   chapter 6Fp601   chapter 6
Fp601 chapter 6
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap2 2 1
Chap2 2 1Chap2 2 1
Chap2 2 1
 
Fp601 chapter 4
Fp601   chapter 4Fp601   chapter 4
Fp601 chapter 4
 
Fp601 chapter 5 -part 1
Fp601   chapter 5 -part 1Fp601   chapter 5 -part 1
Fp601 chapter 5 -part 1
 
Bab 4 simpan kira
Bab 4 simpan kiraBab 4 simpan kira
Bab 4 simpan kira
 
Nota tingkatan 4 prinsip akaun
Nota tingkatan 4 prinsip akaunNota tingkatan 4 prinsip akaun
Nota tingkatan 4 prinsip akaun
 

Similar to Chap1 1.4

3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsbabhishekmathuroffici
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3sotlsoc
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART IIOXUS 20
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Muhammad Shebl Farag
 
Value isnt changing and I cant seem to get the conversion to wor.pdf
Value isnt changing and I cant seem to get the conversion to wor.pdfValue isnt changing and I cant seem to get the conversion to wor.pdf
Value isnt changing and I cant seem to get the conversion to wor.pdfamirthagiftsmadurai
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDrRajeshreeKhande
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Md10 building java gu is
Md10 building java gu isMd10 building java gu is
Md10 building java gu isRakesh Madugula
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programmingvanmathy1
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdffathimaoptical
 
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdfJEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdfMarlouFelixIIICunana
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfflashfashioncasualwe
 

Similar to Chap1 1.4 (20)

3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
java swing
java swingjava swing
java swing
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3
 
swingbasics
swingbasicsswingbasics
swingbasics
 
Java GUI PART II
Java GUI PART IIJava GUI PART II
Java GUI PART II
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1
 
Layout manager
Layout managerLayout manager
Layout manager
 
Value isnt changing and I cant seem to get the conversion to wor.pdf
Value isnt changing and I cant seem to get the conversion to wor.pdfValue isnt changing and I cant seem to get the conversion to wor.pdf
Value isnt changing and I cant seem to get the conversion to wor.pdf
 
LAYOUT.pptx
LAYOUT.pptxLAYOUT.pptx
LAYOUT.pptx
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
Java swing
Java swingJava swing
Java swing
 
Swing
SwingSwing
Swing
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Md10 building java gu is
Md10 building java gu isMd10 building java gu is
Md10 building java gu is
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdfJEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
JEDI Slides-Intro2-Chapter19-Abstract Windowing Toolkit and Swing.pdf
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Oop bai10
Oop bai10Oop bai10
Oop bai10
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Chap1 1.4

  • 1. 1.4 USE LAYOUT1.4 USE LAYOUT MANAGERMANAGER
  • 2.  By the end of the class, student should be able to: ◦ Define the use of layout manager in AWT ◦ Use layout manager in AWT:  FlowLayout  GridLayout  BorderLayout  BoxLayout ◦ Write java program using layout manager
  • 3.  The UI components are placed in containers.  Each container has a layout manager to arrange the GUI components within the container.
  • 4.  FlowLayout  GridLayout  BorderLayout  BoxLayout
  • 6.  Simplest and most basic layout manager  Components arranged in container from left to right in the order in which they were added  When edge of container reached, continues on next line  Can determine the gap between components in pixels.
  • 7.  Three constant (alignment): ◦ FlowLayout.RIGHT ◦ FlowLayout.LEFT ◦ FlowLayout.CENTER
  • 9.  public FlowLayout(int align, int hGap, int vGap) Constructs a new FlowLayout with a specified alignment, horizontal gap and vertical gap. The gaps are the distances in pixel between components.  public FlowLayout(int alignment) Constructs a new FlowLayout with a specified alignment and a default gap of 5 pixels for both horizontal and vertical.  public FlowLayout() Constructs a new FlowLayout with a default center alignment and a default gap of 5 pixels for both horizontal and vertical.
  • 10. import java.awt.*; import javax.swing.*; public class TestFlowLayout extends JFrame { public TestFlowLayout() { super(“Create FlowLayout"); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT,20,10)); for (int i=1; i<9;i++) c.add(new Button("button "+i)); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestFlowLayout s = new TestFlowLayout(); s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } 10 20
  • 11.  Divides container into a grid  Components placed in rows and columns  All components have same width and height ◦ Added starting from top left, then from left to right ◦ When row full, continues on next row, left to right
  • 12.  public GridLayout() Construct a new GridLayout with one column in a single row.  public GridLayout(int rows, int columns) Constructs a new GridLayout with the specified number of rows and columns.
  • 13.  public GridLayout(int rows, int columns, int hGap, int vGap) Constructs a new GridLayout with the specified number of rows and columns, along with specified horizontal and vertical gaps between components.
  • 14. import java.awt.*; import javax.swing.*; public class TestGridLayout extends JFrame { public TestGridLayout() { super(“Create GridLayout"); Container s = getContentPane(); s.setLayout(new GridLayout(3,2,20,10)); for (int i=1; i<7;i++) s.add(new Button("button "+i)); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestGridLayout t = new TestGridLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 15.  Divides the window into 5 areas: ◦ BorderLayout.NORTH - North ◦ BorderLayout. SOUTH - South ◦ BorderLayout. EAST - East ◦ BorderLayout. WEST - West ◦ BorderLayout. CENTER - Center
  • 16.  public BorderLayout() Construct a new BorderLayout without horizontal or vertical gaps  public BorderLayout(int hGap, int vGap) Constructs a new BorderLayout with the specified horizontal and vertical gaps between the components.
  • 17. import java.awt.*; import javax.swing.*; public class TestBorderLayout extends JFrame { public TestBorderLayout() { super(“Create BorderLayout"); Container s = getContentPane(); s.setLayout(new BorderLayout(20,10)); Button bNorth = new Button(“North"); Button bSouth = new Button(“South"); Button bEast = new Button(“East"); Button bWest = new Button(“West"); Button bCenter = new Button(“Center"); s.add(bNorth,BorderLayout.NORTH); s.add(bSouth,BorderLayout.SOUTH); s.add(bEast,BorderLayout.EAST); s.add(bWest,BorderLayout.WEST); s.add(bCenter,BorderLayout.CENTER); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestBorderLayout t = new TestBorderLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 18. import java.awt.*; import javax.swing.*; public class TestBorderLayout extends JFrame { public TestBorderLayout() { super(“Create BorderLayout"); Container s = getContentPane(); s.setLayout(new BorderLayout(20,10)); Button bNorth = new Button(“North"); Button bSouth = new Button(“South"); Button bEast = new Button(“East"); Button bWest = new Button(“West"); Button bCenter = new Button(“Center"); //s.add(bNorth,BorderLayout.NORTH); s.add(bSouth,BorderLayout.SOUTH); s.add(bEast,BorderLayout.EAST); s.add(bWest,BorderLayout.WEST); s.add(bCenter,BorderLayout.CENTER); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestBorderLayout t = new TestBorderLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 19. import java.awt.*; import javax.swing.*; public class TestBorderLayout extends JFrame { public TestBorderLayout() { super(“Create BorderLayout"); Container s = getContentPane(); s.setLayout(new BorderLayout(20,10)); Button bNorth = new Button(“North"); Button bSouth = new Button(“South"); Button bEast = new Button(“East"); Button bWest = new Button(“West"); Button bCenter = new Button(“Center"); s.add(bNorth,BorderLayout.NORTH); s.add(bSouth,BorderLayout.SOUTH); //s.add(bEast,BorderLayout.EAST); s.add(bWest,BorderLayout.WEST); s.add(bCenter,BorderLayout.CENTER); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestBorderLayout t = new TestBorderLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 20. import java.awt.*; import javax.swing.*; public class TestBorderLayout extends JFrame { public TestBorderLayout() { super(“Create BorderLayout"); Container s = getContentPane(); s.setLayout(new BorderLayout(20,10)); Button bNorth = new Button(“North"); Button bSouth = new Button(“South"); Button bEast = new Button(“East"); Button bWest = new Button(“West"); Button bCenter = new Button(“Center"); //s.add(bNorth,BorderLayout.NORTH); s.add(bSouth,BorderLayout.SOUTH); //s.add(bEast,BorderLayout.EAST); //s.add(bWest,BorderLayout.WEST); s.add(bCenter,BorderLayout.CENTER); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestBorderLayout t = new TestBorderLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 21. import java.awt.*; import javax.swing.*; public class TestBorderLayout extends JFrame { public TestBorderLayout() { super(“Create BorderLayout"); Container s = getContentPane(); s.setLayout(new BorderLayout(20,10)); Button bNorth = new Button(“North"); Button bSouth = new Button(“South"); Button bEast = new Button(“East"); Button bWest = new Button(“West"); Button bCenter = new Button(“Center"); s.add(bNorth,BorderLayout.NORTH); s.add(bSouth,BorderLayout.SOUTH); s.add(bEast,BorderLayout.EAST); s.add(bWest,BorderLayout.WEST); //s.add(bCenter,BorderLayout.CENTER); setSize(350,200); setVisible(true); } public static void main(String[] arg) { TestBorderLayout t = new TestBorderLayout(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
  • 22.  A layout manager that allows multiple components to be laid out either vertically or horizontally.  The value of axis can be one of the following: ◦ BoxLayout.X_AXIS ◦ BoxLayout.Y_AXIS ◦ BoxLayout.LINE_AXIS ◦ BoxLayout.PAGE_AXIS
  • 23.  4 layout manager: FlowLayout, BorderLayout, GridLayout and BoxLayout.