SlideShare una empresa de Scribd logo
1 de 14
09 GUIs HUREE University ICT Instructor: M.J LEE
Contents Abstract Window Toolkit Container Frame Panel Layout Manager Flow Layout Border Layout Grid Layout 2
AWT(Abstract Window Toolkit) AWT: the group of classes for GUI in Java 3 ,[object Object]
Component / Container,[object Object]
Panel Use add() method, when adding components Panel can’t be displayed by itself. Therefore, it should be included in Frame Some components are disposed in Panel by Layout Manager 5
6 import java.awt.*;  public class FrameWithPanelextends Frame {  	public FrameWithPanel (String str) {  		super(str);  	}  } Public class FrameWithPanelMain() { 	public static void main (String args[]) { FrameWithPanelfr = new FrameWithPanel(“Panel in Frame"); 		Panel pan = new Panel();    fr.setSize(200,200); 		// a frame fr.setBackground(Color.blue);  fr.setLayout(null);    pan.setSize(100,100); 		// a panel pan.setBackground(Color.yellow);    fr.add(pan);   // put the panel in the frame fr.setVisible(true);  }  } Panel
Layout Manager FlowLayout 	Panel, default Layout manager of Applet BorderLayout 	Window, default Layout manager of Frame GridLayout CardLayout GridBagLayout 7
8 import java.awt.*;  public class ExGui {  	private Frame f; 		// declarationFrame 	private Button b1; 	// declaration Button 	private Button b2; 	public void go() {  		f = new Frame("GUI example");  f.setLayout(new FlowLayout());  	b1 = new Button(“Yes”);  	b2 = new Button(“No");  f.add(b1); 		// append Button on Frame f.add(b2);  f.pack(); 		// instead of “.setSize()” f.setVisible(true);  	}  } public static ExGuiMain() { 	public static void main(String args[]) {  ExGuiguiWindow = new ExGui();  guiWindow.go();  	} } 1. Flow Layout
Layout Manager –1.Flow Layout At above example, which didn't inherit Frame, declared new frame in the class Properties, Flow Layout Manager is a default layout manager of Panel depose components from left to right! depose components at the middle of Frame, as default decide the size of components by itself It is possible to exchange attributes by using constructor 9 setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 40))
Layout Manager –1.Flow Layout Components are disposed at right side. Gap of left and right between components Gap of top and bottom between components (unit: pixel) 10 setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 40)) 1 2 3
11 import java.awt.*;  public class MyFlow {  	private Frame f;  	private Button button1, button2, button3;  	public void go() {  		f = new Frame("Flow Layout"); f.setLayout(new FlowLayout());  		button1 = new Button("Ok"); 	 		button2 = new Button("Open"); 	 		button3 = new Button("Close"); 					f.add(button1);  f.add(button2);  f.add(button3);  f.setSize(100,100);  f.setVisible(true); 	}  } Public class MyFlowMain() { 	public static void main(String args[]) {  MyFlowmflow = new MyFlow();  mflow.go();  	}  }  1. Flow Layout
12 import java.awt.*; public class ExGui2 {  	private Frame f;  	private Button bn, bs, bw, be, bc;  	public void go() {  		f = new Frame("Border Layout");  bn = new Button("B1"); bs = new Button("B2"); bw = new Button("B3"); be = new Button("B4"); bc = new Button("B5"); f.add(bn, BorderLayout.NORTH);  f.add(bs, BorderLayout.SOUTH);  f.add(bw, BorderLayout.WEST); f.add(be, BorderLayout.EAST); f.add(bc, BorderLayout.CENTER);  f.setSize(200,200); f.setVisible(true); 	}  	public static void main(String args[]) {  		ExGui2 guiWindow2 = new ExGui2();  		guiWindow2.go();  	} } 2. Border Layout
13 2. Grid Layout import java.awt.*;  public class TestGrid {  	private Frame f; 	private Button b1, b2, b3, b4, b5, b6; 	public void go() {  	f = new Frame(“Grid Layout"); f.setLayout (new GridLayout(3,2)); b1 = new Button("1"); b2 = new Button("2"); b3 = new Button("3"); b4 = new Button("4");  b5 = new Button("5"); b6 = new Button("6");  f.add(b1);  f.add(b2); f.add(b3); f.add(b4); f.add(b5); f.add(b6); f.pack(); f.setVisible(true);  	}  	public static void main(String args[]) {  TestGrid grid = new TestGrid();  grid.go();  	} }
Layout Manager –3.Grid Layout Add(): components are disposed from left to right, upside to bottom The size of each cell, which is divided by Grid Layout Manager, is same. The number of cells can be defined when they are created with Constructor. f.setLayout (new GridLayout(3,2)); 14

Más contenido relacionado

Similar a 09 gui

import java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfimport java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfapjewellers
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managersswapnac12
 
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
 
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
 
ADVANCED JAVA PROGRAMME
ADVANCED JAVA PROGRAMME ADVANCED JAVA PROGRAMME
ADVANCED JAVA PROGRAMME RRamyaDevi
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3Faiz Bashir
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window ToolkitRutvaThakkar1
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsbabhishekmathuroffici
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics ProgrammingRiccardo Cardin
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTPayal Dungarwal
 
AJP Practical Questions with Solution.docx
AJP Practical Questions with Solution.docxAJP Practical Questions with Solution.docx
AJP Practical Questions with Solution.docxRenuDeshmukh5
 

Similar a 09 gui (20)

LAYOUT.pptx
LAYOUT.pptxLAYOUT.pptx
LAYOUT.pptx
 
import java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdfimport java.awt.;class FlowLayoutDemo {    public static void.pdf
import java.awt.;class FlowLayoutDemo {    public static void.pdf
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
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
 
java2 swing
java2 swingjava2 swing
java2 swing
 
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
 
Oop lecture9 10
Oop lecture9 10Oop lecture9 10
Oop lecture9 10
 
ADVANCED JAVA PROGRAMME
ADVANCED JAVA PROGRAMME ADVANCED JAVA PROGRAMME
ADVANCED JAVA PROGRAMME
 
Chap1 1 4
Chap1 1 4Chap1 1 4
Chap1 1 4
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 
swings.pptx
swings.pptxswings.pptx
swings.pptx
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
Final_Project
Final_ProjectFinal_Project
Final_Project
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics Programming
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWT
 
AJP Practical Questions with Solution.docx
AJP Practical Questions with Solution.docxAJP Practical Questions with Solution.docx
AJP Practical Questions with Solution.docx
 

Último

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 

09 gui

  • 1. 09 GUIs HUREE University ICT Instructor: M.J LEE
  • 2. Contents Abstract Window Toolkit Container Frame Panel Layout Manager Flow Layout Border Layout Grid Layout 2
  • 3.
  • 4.
  • 5. Panel Use add() method, when adding components Panel can’t be displayed by itself. Therefore, it should be included in Frame Some components are disposed in Panel by Layout Manager 5
  • 6. 6 import java.awt.*; public class FrameWithPanelextends Frame { public FrameWithPanel (String str) { super(str); } } Public class FrameWithPanelMain() { public static void main (String args[]) { FrameWithPanelfr = new FrameWithPanel(“Panel in Frame"); Panel pan = new Panel();   fr.setSize(200,200); // a frame fr.setBackground(Color.blue); fr.setLayout(null);   pan.setSize(100,100); // a panel pan.setBackground(Color.yellow);   fr.add(pan); // put the panel in the frame fr.setVisible(true); } } Panel
  • 7. Layout Manager FlowLayout Panel, default Layout manager of Applet BorderLayout Window, default Layout manager of Frame GridLayout CardLayout GridBagLayout 7
  • 8. 8 import java.awt.*; public class ExGui { private Frame f; // declarationFrame private Button b1; // declaration Button private Button b2; public void go() { f = new Frame("GUI example"); f.setLayout(new FlowLayout()); b1 = new Button(“Yes”); b2 = new Button(“No"); f.add(b1); // append Button on Frame f.add(b2); f.pack(); // instead of “.setSize()” f.setVisible(true); } } public static ExGuiMain() { public static void main(String args[]) { ExGuiguiWindow = new ExGui(); guiWindow.go(); } } 1. Flow Layout
  • 9. Layout Manager –1.Flow Layout At above example, which didn't inherit Frame, declared new frame in the class Properties, Flow Layout Manager is a default layout manager of Panel depose components from left to right! depose components at the middle of Frame, as default decide the size of components by itself It is possible to exchange attributes by using constructor 9 setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 40))
  • 10. Layout Manager –1.Flow Layout Components are disposed at right side. Gap of left and right between components Gap of top and bottom between components (unit: pixel) 10 setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 40)) 1 2 3
  • 11. 11 import java.awt.*; public class MyFlow { private Frame f; private Button button1, button2, button3; public void go() { f = new Frame("Flow Layout"); f.setLayout(new FlowLayout()); button1 = new Button("Ok"); button2 = new Button("Open"); button3 = new Button("Close"); f.add(button1); f.add(button2); f.add(button3); f.setSize(100,100); f.setVisible(true); } } Public class MyFlowMain() { public static void main(String args[]) { MyFlowmflow = new MyFlow(); mflow.go(); } } 1. Flow Layout
  • 12. 12 import java.awt.*; public class ExGui2 { private Frame f; private Button bn, bs, bw, be, bc; public void go() { f = new Frame("Border Layout"); bn = new Button("B1"); bs = new Button("B2"); bw = new Button("B3"); be = new Button("B4"); bc = new Button("B5"); f.add(bn, BorderLayout.NORTH); f.add(bs, BorderLayout.SOUTH); f.add(bw, BorderLayout.WEST); f.add(be, BorderLayout.EAST); f.add(bc, BorderLayout.CENTER); f.setSize(200,200); f.setVisible(true); } public static void main(String args[]) { ExGui2 guiWindow2 = new ExGui2(); guiWindow2.go(); } } 2. Border Layout
  • 13. 13 2. Grid Layout import java.awt.*; public class TestGrid { private Frame f; private Button b1, b2, b3, b4, b5, b6; public void go() { f = new Frame(“Grid Layout"); f.setLayout (new GridLayout(3,2)); b1 = new Button("1"); b2 = new Button("2"); b3 = new Button("3"); b4 = new Button("4"); b5 = new Button("5"); b6 = new Button("6"); f.add(b1); f.add(b2); f.add(b3); f.add(b4); f.add(b5); f.add(b6); f.pack(); f.setVisible(true); } public static void main(String args[]) { TestGrid grid = new TestGrid(); grid.go(); } }
  • 14. Layout Manager –3.Grid Layout Add(): components are disposed from left to right, upside to bottom The size of each cell, which is divided by Grid Layout Manager, is same. The number of cells can be defined when they are created with Constructor. f.setLayout (new GridLayout(3,2)); 14