SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
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…

Weitere ähnliche Inhalte

Andere mochten auch

Javaday 2009 php e java
Javaday 2009 php e javaJavaday 2009 php e java
Javaday 2009 php e javaMatteo Baccan
 
Confsl 2010 Facebook Framework
Confsl 2010 Facebook FrameworkConfsl 2010 Facebook Framework
Confsl 2010 Facebook FrameworkMatteo Baccan
 
090613 Ideo
090613 Ideo090613 Ideo
090613 Ideoyuu_2003
 
Bolji svet - Uvodni webinar
Bolji svet  - Uvodni webinarBolji svet  - Uvodni webinar
Bolji svet - Uvodni webinarMaja Vujovic
 
The Mighty Gabby Embodying Resistance in the Creative Process
The Mighty Gabby Embodying Resistance in the Creative Process The Mighty Gabby Embodying Resistance in the Creative Process
The Mighty Gabby Embodying Resistance in the Creative Process Ian Walcott-Skinner
 
技术培训
技术培训技术培训
技术培训yamingd
 
Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...
Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...
Kim Brown, Joint Head of Learning Development & Diversity at London Boroughs ...Paul McElvaney
 
Rob Whiteman - Learning Pool Conference
Rob Whiteman - Learning Pool ConferenceRob Whiteman - Learning Pool Conference
Rob Whiteman - Learning Pool ConferencePaul McElvaney
 
Design Challenge | Pelephone Corporate Website
Design Challenge | Pelephone Corporate WebsiteDesign Challenge | Pelephone Corporate Website
Design Challenge | Pelephone Corporate WebsiteUdi Salant
 
Aag presentatie 3 februari
Aag presentatie 3 februariAag presentatie 3 februari
Aag presentatie 3 februariSjef Kerkhofs
 
Pondres Social Marketing Event preso's
Pondres Social Marketing Event preso'sPondres Social Marketing Event preso's
Pondres Social Marketing Event preso'sSjef Kerkhofs
 
Jammy Create presentation
Jammy Create presentationJammy Create presentation
Jammy Create presentationPaul McElvaney
 
The Public Sector Learning Community
The Public Sector Learning CommunityThe Public Sector Learning Community
The Public Sector Learning CommunityPaul McElvaney
 

Andere mochten auch (20)

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

Ähnlich wie Lecture 16

Ähnlich wie Lecture 16 (20)

3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
Swing
SwingSwing
Swing
 
Swing
SwingSwing
Swing
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Swing
SwingSwing
Swing
 
Chap1 1.4
Chap1 1.4Chap1 1.4
Chap1 1.4
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Java card and flow layout
Java card and flow layoutJava card and flow layout
Java card and flow layout
 
java swing
java swingjava swing
java swing
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
 
Java
JavaJava
Java
 
Chap1 1 4
Chap1 1 4Chap1 1 4
Chap1 1 4
 
Javalayout
JavalayoutJavalayout
Javalayout
 
swingbasics
swingbasicsswingbasics
swingbasics
 
Layout manager
Layout managerLayout manager
Layout manager
 
Problem oriented software engineering01
Problem oriented software engineering01Problem oriented software engineering01
Problem oriented software engineering01
 
Java swing
Java swingJava swing
Java swing
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 

Mehr von Debasish Pratihari (19)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Kürzlich hochgeladen

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Kürzlich hochgeladen (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

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…