0% found this document useful (0 votes)
4 views26 pages

AWT Concepts

The document provides an overview of the Abstract Window Toolkit (AWT) in Java, detailing the various GUI components such as Button, Checkbox, and Frame, along with their creation and initialization. It discusses the role of layout managers in organizing components within containers and mentions the five predefined layout manager classes. Additionally, it highlights the importance of event-driven programming for enhancing interactivity in Java GUIs.

Uploaded by

sanyamdiwan0000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

AWT Concepts

The document provides an overview of the Abstract Window Toolkit (AWT) in Java, detailing the various GUI components such as Button, Checkbox, and Frame, along with their creation and initialization. It discusses the role of layout managers in organizing components within containers and mentions the five predefined layout manager classes. Additionally, it highlights the importance of event-driven programming for enhancing interactivity in Java GUIs.

Uploaded by

sanyamdiwan0000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

AWT Concepts

AWT Abstract Window Toolkit


Classes for AWT GUIs
Classes for AWT GUIs
Classes for AWT GUIs
GUI with Components
• Components are a group of classes which belong to the class Component.
• The basic and frequently used components are Button,Checkbox, Choice, Frame,
Panel, Label, List, Scrollbar, TextArea, TextField
• For each of the above components, there are corresponding classes.
• Using a class, an object of desired type can be created.
• Each class have their own constructors for initialization of the objects.
• When an object is created and initialized, it then can be placed on an applet by the
add() method, which is defined in their corresponding classes.
Methods in Component Classes
Class Frame : Constructors
Creating a Frame
Class Button
Creating a Button
Class Checkbox
Creating a Checkbox
Class Label
Creating a Label
Class TextField
Creating a TextField
Creating a List
Creating a Choice
Layout MAnagers
• It is a tedious process (particularly with a large number of components) to place components on the screen (it has to be specified
explicitly).
• To tackle this, AWT includes the notion of layout managers: the layout of components in a container may be governed by a layout
manager.
• A Container in Java is nothing but an applet which generally contains number of GUI attributes such as Frame, Panel, Label, Button,
etc.
• Each Container object has a layout manger which is an instance of any class that implements the Layout Manager interface.
• Each component, such as a Panel, or a Frame has a default layout manager associated with it which may be changed by the Java
developer when an instance of that container is created.
• Each layout manager keeps track of a list of Components. The layout manager is notified each time one adds a Component to a
Panel, for example.
• Java has the following five predefined layout manager classes: FlowLayout BorderLayout GridLayout CardLayout
Flow Layout
Creating Border Layout
Creating Grid Layout
Creating Card Layout
Event Handling

• To add life to the components


• Java GUI supports event-driven programming
• The device usually handled are: Mouse & Keyboard
Event and Component Relation

You might also like