SlideShare a Scribd company logo
UNIT 5
CHAPTER :1 AWT CLASSES &
WINDOWS FUNDAMENTALS
AWT CLASSES
5
To build a GUI...
• Make somewhere to display things—usually a
Frame or Dialog (for an application), or an Applet
• Create some Components, such as buttons, text
areas, panels, etc.
• Add your Components to your display area
• Arrange, or lay out, your Components
• Attach Listeners to your Components
– Interacting with a Component causes an Event to occur
– A Listener gets a message when an interesting event
occurs, and executes some code to deal with it
6
An Applet HIERARCHY
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
…so you can display things in an Applet
AWT –
Class Hierarchy
Panel
Button
Checkbox
Choice
Label
List
Component
Container Frame
Window
TextArea
TextField
TextComponent
Note: There are more classes, however,
these are what are covered in this chapter
9
Example: A "Life" applet
Container (Applet)
Containers (Panels)
Component (Canvas)
Components (Buttons)
Components (Labels)
Components (TextFields)
10
Some types of components
Label Button
Button
Checkbox
Choice
List
Scrollbar
TextField TextArea
CheckboxGroup
Checkbox
11
Creating a Graphical User Interface
• GUI programming in Java is based on three concepts:
– Components. A component is an object that the user can see on
the screen and—in most cases—interact with.
– Containers. A container is a component that can hold other
components.
– Events. An event is an action triggered by the user, such as a key
press or mouse click.
• Designing a graphical user interface involves creating
components, putting them into containers, and arranging
for the program to respond to events.
COMPONENT:
Component class is at the top of the AWT hierarchy. Its an abstract class that encapsulates all
of the attributes of a visual component . All the user interface elements that are displayed on
the screen and that interact with the user are subclasses of Component.
CONTAINER:
The Container class is a subclass of Component. It has additional methods that allow other
Component objects to be nested within it. other container objects can be stored inside a
Container. Various layouts can be used by implementing Layout Manager.
PANEL:
It’s a subclass of Container . It does not have any new methods .It implements Container .
Panel is the super class for Applet . The output on the screen directed to an Applet is actually
drawn on the surface of Panel object .A panel is a window that does not has a title bar ,Menu
bar or a border.
Components can be added to the Panel using add() method inherited from Container. Once
the components are added they can be resized , positioned using setSize()
,setLocation(),setBounds() etc.
WINDOW: A Window class creates a top-level window.Window is not contained within any
other object. It is placed directly on the desktop.
FRAME:
It’s a subclass of Window and has a title bar, menu bar and resizing corners also. When a
Frame object is created a warning msg such as “Java Applet Window” will be displayed to
ensure the user that the Frame is created by the Applet Window not by any other running
software.
CANVAS:
It is not the hierarchy of Frame of applet. But it is another type of Window used in GUI.
Working with Frame Windows
Frames are most widely used after the usage of applets. The Constructors use are
The first form creates the window without ant title. The second form creates the window with a
title . Windows can be resized , made to visible and closed also using the following methods.
Closing the windows can be done by either using setVisible(false) or using windowClosing()
method of windowListener interface.
AWT controls, Listeners
AWT controls, Listeners
AWT controls, Listeners
AWT controls, Listeners
AWT controls, Listeners

More Related Content

Similar to AWT controls, Listeners

Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
RutvaThakkar1
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
Ankit Dubey
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
Sohanur63
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
PriyanshiPrajapati27
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
JONDHLEPOLY
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
Hemo Chella
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
Hemo Chella
 
AWT.pptx
AWT.pptxAWT.pptx
AWT.pptx
FAHMIDAASEEZ1
 
Applet in java
Applet in javaApplet in java
Applet in java
Jancypriya M
 
Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)
Chhom Karath
 
Computer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptxComputer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptx
jonathancapitulo2
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
renuka gavli
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
PBMaverick
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
DrDGayathriDevi
 
Gui
GuiGui

Similar to AWT controls, Listeners (20)

Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
AWT Packages , Containers and Components
AWT Packages , Containers and ComponentsAWT Packages , Containers and Components
AWT Packages , Containers and Components
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
AWT.pptx
AWT.pptxAWT.pptx
AWT.pptx
 
28 awt
28 awt28 awt
28 awt
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)Chapter iii(building a simple user interface)
Chapter iii(building a simple user interface)
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Computer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptxComputer Programming NC III - Java Swing.pptx
Computer Programming NC III - Java Swing.pptx
 
Introdu.awt
Introdu.awtIntrodu.awt
Introdu.awt
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
 
Gui
GuiGui
Gui
 

More from Kalai Selvi

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providers
Kalai Selvi
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologies
Kalai Selvi
 
cloud computing
cloud computingcloud computing
cloud computing
Kalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
Kalai Selvi
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptx
Kalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
Kalai Selvi
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.ppt
Kalai Selvi
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.ppt
Kalai Selvi
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
Kalai Selvi
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
Kalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
Kalai Selvi
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AI
Kalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
Kalai Selvi
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
Kalai Selvi
 
Unit 1 part 2
Unit 1  part 2Unit 1  part 2
Unit 1 part 2
Kalai Selvi
 
Unit 1 part 1
Unit 1   part 1Unit 1   part 1
Unit 1 part 1
Kalai Selvi
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
Kalai Selvi
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
Kalai Selvi
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
Kalai Selvi
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
Kalai Selvi
 

More from Kalai Selvi (20)

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providers
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologies
 
cloud computing
cloud computingcloud computing
cloud computing
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptx
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.ppt
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.ppt
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AI
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Unit 1 part 2
Unit 1  part 2Unit 1  part 2
Unit 1 part 2
 
Unit 1 part 1
Unit 1   part 1Unit 1   part 1
Unit 1 part 1
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 

Recently uploaded

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

AWT controls, Listeners

  • 1. UNIT 5 CHAPTER :1 AWT CLASSES & WINDOWS FUNDAMENTALS
  • 3.
  • 4.
  • 5. 5 To build a GUI... • Make somewhere to display things—usually a Frame or Dialog (for an application), or an Applet • Create some Components, such as buttons, text areas, panels, etc. • Add your Components to your display area • Arrange, or lay out, your Components • Attach Listeners to your Components – Interacting with a Component causes an Event to occur – A Listener gets a message when an interesting event occurs, and executes some code to deal with it
  • 7.
  • 8. AWT – Class Hierarchy Panel Button Checkbox Choice Label List Component Container Frame Window TextArea TextField TextComponent Note: There are more classes, however, these are what are covered in this chapter
  • 9. 9 Example: A "Life" applet Container (Applet) Containers (Panels) Component (Canvas) Components (Buttons) Components (Labels) Components (TextFields)
  • 10. 10 Some types of components Label Button Button Checkbox Choice List Scrollbar TextField TextArea CheckboxGroup Checkbox
  • 11. 11 Creating a Graphical User Interface • GUI programming in Java is based on three concepts: – Components. A component is an object that the user can see on the screen and—in most cases—interact with. – Containers. A container is a component that can hold other components. – Events. An event is an action triggered by the user, such as a key press or mouse click. • Designing a graphical user interface involves creating components, putting them into containers, and arranging for the program to respond to events.
  • 12. COMPONENT: Component class is at the top of the AWT hierarchy. Its an abstract class that encapsulates all of the attributes of a visual component . All the user interface elements that are displayed on the screen and that interact with the user are subclasses of Component. CONTAINER: The Container class is a subclass of Component. It has additional methods that allow other Component objects to be nested within it. other container objects can be stored inside a Container. Various layouts can be used by implementing Layout Manager. PANEL: It’s a subclass of Container . It does not have any new methods .It implements Container . Panel is the super class for Applet . The output on the screen directed to an Applet is actually drawn on the surface of Panel object .A panel is a window that does not has a title bar ,Menu bar or a border. Components can be added to the Panel using add() method inherited from Container. Once the components are added they can be resized , positioned using setSize() ,setLocation(),setBounds() etc. WINDOW: A Window class creates a top-level window.Window is not contained within any other object. It is placed directly on the desktop.
  • 13. FRAME: It’s a subclass of Window and has a title bar, menu bar and resizing corners also. When a Frame object is created a warning msg such as “Java Applet Window” will be displayed to ensure the user that the Frame is created by the Applet Window not by any other running software. CANVAS: It is not the hierarchy of Frame of applet. But it is another type of Window used in GUI.
  • 14. Working with Frame Windows Frames are most widely used after the usage of applets. The Constructors use are The first form creates the window without ant title. The second form creates the window with a title . Windows can be resized , made to visible and closed also using the following methods.
  • 15. Closing the windows can be done by either using setVisible(false) or using windowClosing() method of windowListener interface.

Editor's Notes

  1. This slide shows the hierarchy of classes which will be covered in this chapter. If you check the Java API documentation, you will note that there are many more classes in the java.awt package.