SlideShare a Scribd company logo
Abstract Windowing Toolkit
Session 3
Abstract Windowing Toolkit / 2 of 29
Objectives
 Discuss Containers and Components
 Frame
 Panel
 Label
 TextFields and TextAreas
 Checkboxes and RadioButtons
 Choice
 Identify events generated by components
 Create a standalone AWT application
 Describe Abstract Windowing Toolkit (AWT)
Abstract Windowing Toolkit / 3 of 29
Introduction
 These make the language richer in terms of creating
graphical objects that can be controlled by the
developer as well as the user.
 One of the most important outcomes of this is that
languages have happened to be GUI based.
 In this session we discuss how Java supports GUI
features and how they are implemented.
 As on date, software applications have become user-
friendlier because of introducing graphics in user
interfaces
Abstract Windowing Toolkit / 4 of 29
Abstract Windowing Toolkit
 Abstract Windowing Toolkit (AWT) is a set
of Java classes that allow us to create a GUI
 AWT provides items which enable creation of
an attractive and efficient GUI
 Graphical User Interface (GUI) is used to
accept input through a keyboard or a mouse
Abstract Windowing Toolkit / 5 of 29
Containers
 It can be drawn or painted
 Container class in the java.awt package
directly or indirectly derives two commonly
used containers – Frame and Panel
 Frame is a separate window and has borders
 Panel is an area without borders and is
contained within a window
 An area that can hold elements
Abstract Windowing Toolkit / 6 of 29
Containers - Frame
 Can be a component or a container
 Can be created using constructors
 Some of these constructors are:
 Frame()

Creates a Frame which is invisible
 Frame(String Title)

Creates an invisible Frame with given title
 A window that is independent of an applet
and of the browser
Abstract Windowing Toolkit / 7 of 29
Example
Output
Abstract Windowing Toolkit / 8 of 29
Containers - Panel
 Simplest way to create a panel is through its
constructor Panel( )
 A panel has to be added to a frame
 The frame will be visible only when the two
methods – setSize( ) and setVisible( ) are set
 Used to group a number of components
together
Abstract Windowing Toolkit / 9 of 29
Example
Output
Abstract Windowing Toolkit / 10 of 29
Component
 Examples include textfields, labels,
checkboxes, textareas etc.
 Some advanced components include
scrollbars, scrollpanes and dialogs
 Anything that can be placed on a user
interface and can be made visible or resized
Abstract Windowing Toolkit / 11 of 29
Hierarchy of classes in Java
Component
Button Checkbox Container Choice Canvas
TextComponent
Label
Panel Window
Applet Frame Dialog
TextArea TextField
Abstract Windowing Toolkit / 12 of 29
Various components
Label Text field
Checkbox
Radio button
Button
Text Area
Abstract Windowing Toolkit / 13 of 29
Label
 Not user-editable
 Can be created using one of the following constructors:
 Label( )
Creates an empty label
 Label(String labeltext)
Creates a label with a given text
 Label(String labeltext, int alignment)
Creates a label with given alignment where alignment
can be Label.LEFT, Label.RIGHT or Label.CENTER
 Generally used to indicate the purpose of an item
Abstract Windowing Toolkit / 14 of 29
Textfield
 Generally accepts one line of input
 Can be created using one of the following constructors:
 Textfield()
Creates a new textfield
 Textfield(int columns)
Creates a new textfield with given number of columns
 Textfield(String s)
Creates a new textfield with the given string
 Textfield(String s, int columns)
Creates a new textfield with given string and given
number of columns
 GUI element used to input text
Abstract Windowing Toolkit / 15 of 29
Example
Output
Abstract Windowing Toolkit / 16 of 29
TextArea
 Includes a scrollbar
 TextArea can be created using some of the following
constructors given below:
 TextArea( )
Creates a new TextArea
 TextArea(int rows, int cols)
Creates a new TextArea with given number of rows and
columns
 TextArea(String text, int rows, int cols)
Creates a new TextArea with given string, given number
of rows and columns
 Used when text is to be accepted has two or more lines
Abstract Windowing Toolkit / 17 of 29
Example
Output
Abstract Windowing Toolkit / 18 of 29
Button
 The easiest way to trap user action
 Can create buttons in Java using any of the
following constructors
 Button()
Creates a new Button.
 Button(String text)
Creates a new Button with the given String
 Part of GUI
Abstract Windowing Toolkit / 19 of 29
Example
Output
Abstract Windowing Toolkit / 20 of 29
Checkbox
 Checkboxes in Java can be created using
constructors.
 Some of these constructors are:
 Checkbox()
Creates an empty textbox
 Checkbox(String text)
Creates a checkbox with given string as label
 Used for multi-option user input that the user
may select or deselect by clicking them.
Abstract Windowing Toolkit / 21 of 29
Example
Output
Abstract Windowing Toolkit / 22 of 29
Radiobuttons
 Only one button in a radiobutton group can
be selected.
 First create a CheckboxGroup object
 CheckboxGroup cg=new CheckboxGroup();
 Then create each of the radio buttons
 Checkbox male=Checkbox(“male”,cg,true);
 Checkbox female=Checkbox(“female”,cg,false);
 Used as option button to specify choices.
Abstract Windowing Toolkit / 23 of 29
Example
Output
Abstract Windowing Toolkit / 24 of 29
Lists
 User may select one or more items
 Created using a number of strings or text
values
 Choice class enables us to create multiple
item lists
 Choice moviestars=new Choice();
 Add items using the addItem() method
 moviestars.addItem(“Antonio Banderas”);
 moviestars.addItem(“Leonardo Dicaprio”);
 Displays a list of choices to the user
Abstract Windowing Toolkit / 25 of 29
Example
Output
Abstract Windowing Toolkit / 26 of 29
Event handling
with components (1)
 Event Delegation Model is used to handle
events
 This process allows the program to register
handlers called ‘listeners’ with objects whose
events need to be captured
 Handlers are automatically called when an
event takes place
 An event is generated whenever a user clicks a
mouse, presses or releases a key
Abstract Windowing Toolkit / 27 of 29
Event handling
with components (2)
 Steps to be followed –
 Associate the class with the appropriate listener
interface
 Identify all components that generate events
 Identify all events to be handled
 Implement the methods of the listener and write
the event handling code within the methods
 Event listeners are implemented as interfaces
in Java
Abstract Windowing Toolkit / 28 of 29
Event handling
with components (3)
Event Class Description Interface
ActionEvent Button is pressed, list item is
double clicked or a menu is
selected
ActionListener
AdjustmentEvent When scrollbar is used AdjustmentListener
ComponentEvent Component is resized,
moved, hidden or made
visible
ComponentListener
FocusEvent Component gains or loses
keyboard focus
FocusListener
Abstract Windowing Toolkit / 29 of 29
Event handling
with components (4)
Event Class Description Interface
ItemEvent When a menu item is selected
or deselected or when a
checkbox or list item is clicked
ItemListener
WindowEvent Window is activated, closed,
opened or quit
WindowListener
TextEvent Value of a text field or text area
is changed
TextListener
MouseEvent Mouse is moved, clicked,
dragged or released
MouseListener Mouse
MotionListener
KeyEvent Input is received from the
keyboard
KeyListener
Want to contact Unit Nexus
 Unit Nexus Zirakpur Official Website
 Like Unit Nexus Pvt. Ltd. On Facebook
 Add Unit Nexus to your professional Network
on Linked In
 Company Profile of Unit Nexus
Java Language Fundamentals / 30 of 28

More Related Content

PPT
PPTX
Awt components
PPTX
PPT
28 awt
PPT
Awt controls ppt
PPT
Windows Programming with AWT
PPTX
tL19 awt
PPTX
Java awt (abstract window toolkit)
Awt components
28 awt
Awt controls ppt
Windows Programming with AWT
tL19 awt
Java awt (abstract window toolkit)

What's hot (20)

PPT
Basic of Abstract Window Toolkit(AWT) in Java
PDF
Java awt tutorial javatpoint
PPT
25 awt
PPSX
Dr. Rajeshree Khande :Introduction to Java AWT
PPT
Java awt
PDF
The AWT and Swing
PPT
Awt and swing in java
PPT
GUI Programming In Java
PPT
Java swing
PDF
PPTX
JAVA AWT
PPTX
GUI components in Java
PPTX
java-Unit4 chap2- awt controls and layout managers of applet
PPT
Swing and AWT in java
PPTX
Event handling
PPT
Java: GUI
PPTX
Java- GUI- Mazenet solution
PPTX
GUI Programming with Java
PPTX
Java chapter 7
Basic of Abstract Window Toolkit(AWT) in Java
Java awt tutorial javatpoint
25 awt
Dr. Rajeshree Khande :Introduction to Java AWT
Java awt
The AWT and Swing
Awt and swing in java
GUI Programming In Java
Java swing
JAVA AWT
GUI components in Java
java-Unit4 chap2- awt controls and layout managers of applet
Swing and AWT in java
Event handling
Java: GUI
Java- GUI- Mazenet solution
GUI Programming with Java
Java chapter 7
Ad

Viewers also liked (17)

PDF
Hướng dẫn sử dụng máy photocopy toshiba E352
PPT
Great news update
PDF
Demo deck truckee
PPTX
Harley davidson india
PPT
Benchmarking for Social Media: Get Social Brevard Presentation
PPT
Turnitin Plagiarism Checker - Introduction
DOC
Economics basic concepts FOR MBA LEVEL WITH DEFINITION WHAT IS , WHAT IF
PDF
Lyme Disease: A Short Story
PDF
Ideate
PPTX
Pptpresentation
PPTX
Empathize and define
PPT
Dolor abdominal agudo
PPTX
260511 machilove chiba
PDF
Cincy Typing Challenge Typewriter Display
PDF
GAME THEORY NOTES FOR ECONOMICS HONOURS FOR ALL UNIVERSITIES BY SOURAV SIR'S ...
PPTX
Raquira
PPT
龔建嘉Ted報名
Hướng dẫn sử dụng máy photocopy toshiba E352
Great news update
Demo deck truckee
Harley davidson india
Benchmarking for Social Media: Get Social Brevard Presentation
Turnitin Plagiarism Checker - Introduction
Economics basic concepts FOR MBA LEVEL WITH DEFINITION WHAT IS , WHAT IF
Lyme Disease: A Short Story
Ideate
Pptpresentation
Empathize and define
Dolor abdominal agudo
260511 machilove chiba
Cincy Typing Challenge Typewriter Display
GAME THEORY NOTES FOR ECONOMICS HONOURS FOR ALL UNIVERSITIES BY SOURAV SIR'S ...
Raquira
龔建嘉Ted報名
Ad

Similar to AWT information (20)

PDF
AWT (Abstract Window Toolkit) Controls.pdf
PDF
Ajp notes-chapter-01
PDF
GUI.pdf
PDF
Ajp notes-chapter-01
PPTX
Java Abstract Window Toolkit (AWT) Presentation. 2024
PPTX
Java Abstract Window Toolkit (AWT) Presentation. 2024
PPTX
AbstractWindowToolkit33333333333333.pptx
PDF
Python - gui programming (tkinter)
PDF
UNIT-2-AJAVA.pdf
PPTX
AWT Packages , Containers and Components
PPT
Unit 5.133333333333333333333333333333333.ppt
PPTX
awt and swing new (Abstract Window Toolkit).pptx
PPT
engineeringdsgtnotesofunitfivesnists.ppt
PPTX
ITE 1122_ AWT and SWING.pptx
PPTX
Chap 1 - Introduction GUI.pptx
PPTX
Graphical User Interface
PPT
PPTX
Vb.net ide
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
PPTX
Graphical User Interface (GUI)
AWT (Abstract Window Toolkit) Controls.pdf
Ajp notes-chapter-01
GUI.pdf
Ajp notes-chapter-01
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
AbstractWindowToolkit33333333333333.pptx
Python - gui programming (tkinter)
UNIT-2-AJAVA.pdf
AWT Packages , Containers and Components
Unit 5.133333333333333333333333333333333.ppt
awt and swing new (Abstract Window Toolkit).pptx
engineeringdsgtnotesofunitfivesnists.ppt
ITE 1122_ AWT and SWING.pptx
Chap 1 - Introduction GUI.pptx
Graphical User Interface
Vb.net ide
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Graphical User Interface (GUI)

More from Unit Nexus Pvt. Ltd. (8)

PPT
Session4 applets
PPT
Learn Java language fundamentals with Unit nexus
PPT
introduction to java-final with Unit Nexus
PPT
Unit Nexus offering Java ring training
PDF
Core Java tutorial at Unit Nexus
PPTX
Unit nexus school presentation
PPTX
Client review unit nexus
PDF
Unit Nexus Pvt- Ltd-Company profile unipl
Session4 applets
Learn Java language fundamentals with Unit nexus
introduction to java-final with Unit Nexus
Unit Nexus offering Java ring training
Core Java tutorial at Unit Nexus
Unit nexus school presentation
Client review unit nexus
Unit Nexus Pvt- Ltd-Company profile unipl

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
RMMM.pdf make it easy to upload and study
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Complications of Minimal Access Surgery at WLH
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
master seminar digital applications in india
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Anesthesia in Laparoscopic Surgery in India
Microbial disease of the cardiovascular and lymphatic systems
RMMM.pdf make it easy to upload and study
Yogi Goddess Pres Conference Studio Updates
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
What if we spent less time fighting change, and more time building what’s rig...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Classroom Observation Tools for Teachers
Complications of Minimal Access Surgery at WLH
A systematic review of self-coping strategies used by university students to ...
master seminar digital applications in india
Module 4: Burden of Disease Tutorial Slides S2 2025
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
01-Introduction-to-Information-Management.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
History, Philosophy and sociology of education (1).pptx
Weekly quiz Compilation Jan -July 25.pdf

AWT information

  • 2. Abstract Windowing Toolkit / 2 of 29 Objectives  Discuss Containers and Components  Frame  Panel  Label  TextFields and TextAreas  Checkboxes and RadioButtons  Choice  Identify events generated by components  Create a standalone AWT application  Describe Abstract Windowing Toolkit (AWT)
  • 3. Abstract Windowing Toolkit / 3 of 29 Introduction  These make the language richer in terms of creating graphical objects that can be controlled by the developer as well as the user.  One of the most important outcomes of this is that languages have happened to be GUI based.  In this session we discuss how Java supports GUI features and how they are implemented.  As on date, software applications have become user- friendlier because of introducing graphics in user interfaces
  • 4. Abstract Windowing Toolkit / 4 of 29 Abstract Windowing Toolkit  Abstract Windowing Toolkit (AWT) is a set of Java classes that allow us to create a GUI  AWT provides items which enable creation of an attractive and efficient GUI  Graphical User Interface (GUI) is used to accept input through a keyboard or a mouse
  • 5. Abstract Windowing Toolkit / 5 of 29 Containers  It can be drawn or painted  Container class in the java.awt package directly or indirectly derives two commonly used containers – Frame and Panel  Frame is a separate window and has borders  Panel is an area without borders and is contained within a window  An area that can hold elements
  • 6. Abstract Windowing Toolkit / 6 of 29 Containers - Frame  Can be a component or a container  Can be created using constructors  Some of these constructors are:  Frame()  Creates a Frame which is invisible  Frame(String Title)  Creates an invisible Frame with given title  A window that is independent of an applet and of the browser
  • 7. Abstract Windowing Toolkit / 7 of 29 Example Output
  • 8. Abstract Windowing Toolkit / 8 of 29 Containers - Panel  Simplest way to create a panel is through its constructor Panel( )  A panel has to be added to a frame  The frame will be visible only when the two methods – setSize( ) and setVisible( ) are set  Used to group a number of components together
  • 9. Abstract Windowing Toolkit / 9 of 29 Example Output
  • 10. Abstract Windowing Toolkit / 10 of 29 Component  Examples include textfields, labels, checkboxes, textareas etc.  Some advanced components include scrollbars, scrollpanes and dialogs  Anything that can be placed on a user interface and can be made visible or resized
  • 11. Abstract Windowing Toolkit / 11 of 29 Hierarchy of classes in Java Component Button Checkbox Container Choice Canvas TextComponent Label Panel Window Applet Frame Dialog TextArea TextField
  • 12. Abstract Windowing Toolkit / 12 of 29 Various components Label Text field Checkbox Radio button Button Text Area
  • 13. Abstract Windowing Toolkit / 13 of 29 Label  Not user-editable  Can be created using one of the following constructors:  Label( ) Creates an empty label  Label(String labeltext) Creates a label with a given text  Label(String labeltext, int alignment) Creates a label with given alignment where alignment can be Label.LEFT, Label.RIGHT or Label.CENTER  Generally used to indicate the purpose of an item
  • 14. Abstract Windowing Toolkit / 14 of 29 Textfield  Generally accepts one line of input  Can be created using one of the following constructors:  Textfield() Creates a new textfield  Textfield(int columns) Creates a new textfield with given number of columns  Textfield(String s) Creates a new textfield with the given string  Textfield(String s, int columns) Creates a new textfield with given string and given number of columns  GUI element used to input text
  • 15. Abstract Windowing Toolkit / 15 of 29 Example Output
  • 16. Abstract Windowing Toolkit / 16 of 29 TextArea  Includes a scrollbar  TextArea can be created using some of the following constructors given below:  TextArea( ) Creates a new TextArea  TextArea(int rows, int cols) Creates a new TextArea with given number of rows and columns  TextArea(String text, int rows, int cols) Creates a new TextArea with given string, given number of rows and columns  Used when text is to be accepted has two or more lines
  • 17. Abstract Windowing Toolkit / 17 of 29 Example Output
  • 18. Abstract Windowing Toolkit / 18 of 29 Button  The easiest way to trap user action  Can create buttons in Java using any of the following constructors  Button() Creates a new Button.  Button(String text) Creates a new Button with the given String  Part of GUI
  • 19. Abstract Windowing Toolkit / 19 of 29 Example Output
  • 20. Abstract Windowing Toolkit / 20 of 29 Checkbox  Checkboxes in Java can be created using constructors.  Some of these constructors are:  Checkbox() Creates an empty textbox  Checkbox(String text) Creates a checkbox with given string as label  Used for multi-option user input that the user may select or deselect by clicking them.
  • 21. Abstract Windowing Toolkit / 21 of 29 Example Output
  • 22. Abstract Windowing Toolkit / 22 of 29 Radiobuttons  Only one button in a radiobutton group can be selected.  First create a CheckboxGroup object  CheckboxGroup cg=new CheckboxGroup();  Then create each of the radio buttons  Checkbox male=Checkbox(“male”,cg,true);  Checkbox female=Checkbox(“female”,cg,false);  Used as option button to specify choices.
  • 23. Abstract Windowing Toolkit / 23 of 29 Example Output
  • 24. Abstract Windowing Toolkit / 24 of 29 Lists  User may select one or more items  Created using a number of strings or text values  Choice class enables us to create multiple item lists  Choice moviestars=new Choice();  Add items using the addItem() method  moviestars.addItem(“Antonio Banderas”);  moviestars.addItem(“Leonardo Dicaprio”);  Displays a list of choices to the user
  • 25. Abstract Windowing Toolkit / 25 of 29 Example Output
  • 26. Abstract Windowing Toolkit / 26 of 29 Event handling with components (1)  Event Delegation Model is used to handle events  This process allows the program to register handlers called ‘listeners’ with objects whose events need to be captured  Handlers are automatically called when an event takes place  An event is generated whenever a user clicks a mouse, presses or releases a key
  • 27. Abstract Windowing Toolkit / 27 of 29 Event handling with components (2)  Steps to be followed –  Associate the class with the appropriate listener interface  Identify all components that generate events  Identify all events to be handled  Implement the methods of the listener and write the event handling code within the methods  Event listeners are implemented as interfaces in Java
  • 28. Abstract Windowing Toolkit / 28 of 29 Event handling with components (3) Event Class Description Interface ActionEvent Button is pressed, list item is double clicked or a menu is selected ActionListener AdjustmentEvent When scrollbar is used AdjustmentListener ComponentEvent Component is resized, moved, hidden or made visible ComponentListener FocusEvent Component gains or loses keyboard focus FocusListener
  • 29. Abstract Windowing Toolkit / 29 of 29 Event handling with components (4) Event Class Description Interface ItemEvent When a menu item is selected or deselected or when a checkbox or list item is clicked ItemListener WindowEvent Window is activated, closed, opened or quit WindowListener TextEvent Value of a text field or text area is changed TextListener MouseEvent Mouse is moved, clicked, dragged or released MouseListener Mouse MotionListener KeyEvent Input is received from the keyboard KeyListener
  • 30. Want to contact Unit Nexus  Unit Nexus Zirakpur Official Website  Like Unit Nexus Pvt. Ltd. On Facebook  Add Unit Nexus to your professional Network on Linked In  Company Profile of Unit Nexus Java Language Fundamentals / 30 of 28