Chapter One: Debre Markos University Department of Computer Science
Chapter One: Debre Markos University Department of Computer Science
Chapter One: Debre Markos University Department of Computer Science
Chapter One
AWT AND SWING
Advanced Programming(CoSc2084)
03/18/2021
AWT AND SWING
* GUI stands for Graphical User Interface, a term used not only
in Java but in all programming languages that support the
development of GUIs. .
* It is made up of graphical components (e.g., buttons, labels,
windows) through which the user can interact with the page or
application
* Abstract Windows Toolkit (AWT) is JAVA’s original platform
dependent windowing, graphics, and user-interface widget toolkit
preceding swing.
* Swing API is a set of extensible GUI Components to ease the
developer's life to create JAVA based Front End/GUI Applications.
* It is also part of Java Foundation Classes.
* It is built on top of AWT API and acts as a replacement of AWT API,
since it has almost every control corresponding to AWT controls.
AWT AND SWING
Swing Features
* Light Weight- Swing components are independent of native
Operating System's API as Swing API controls are rendered
mostly using pure JAVA code instead of underlying operating
system calls.
* Rich Control- Swing provides a rich set of advanced controls
like Tree, TabbedPane, slider, colorpicker, and table controls.
* Highly Customizable - Swing controls can be customized in a
very easy way as visual appearance is independent of internal
representation.
* Pluggable look-and-feel - SWING based GUI Application look
and feel can be changed at run-time, based on available
values.
AWT AND SWING
AWT components are platform Swing components are made in purely in java
dependent and they are platform independent
AWT components require java.awt Swing components require java. swing package
package
There are no different look and feel in There are different look and feel in Swing
AWT
AWT is a thin layer of code on top of Swing is much larger and has very much richer
the OS functionality
* Behavior: These are the events which occur when the user
interacts with UI elements. This part will be covered in the
Event Handling chapter
Every SWING controls inherits properties from the following Component
class hierarchy.
* Sub classes of Container are called as Container. For example, JPanel, JFrame
and JWindow.
* Following is the list of commonly used containers while designed GUI using
SWING.
Container Container description
Name
JFrame A JFrame is a top-level window with a title and a
border. Each program that uses Swing components
has at least one top-level container, which is the root
of the containment hierarchy .
JPanel JPanel is the simplest container. It provides space in
which any other component can be placed, including
other panels.
JWindow A JWindow object is a top-level window with no
borders and no menu bar.
No Constructor & Description
JFrame ()
Constructs a new frame that is initially invisible.
JFrame (GraphicsConfigurationgc)
Creates a Frame in the specified GraphicsConfiguration of a screen device and
a blank title.
JFrame (String title)
Creates a new, initially invisible Frame with the specified title.
KeyEvent
On entering the character, the Key event is generated.
MouseEvent
This event indicates a mouse action occurred in a component.
WindowEvent
The object of this class represents the change in the state of a window.
AWTEventIt is the root event class for all SWING events. This class and its
subclasses replace the original java.awt.Eventclass.
ComponentEvent
The object of this class represents the change in the state of a window.
ContainerEvent
The object of this class represents the change in the state of a window.
MouseMotionEvent
The object of this class represents the change in the state of a window.
OU
K Y
A N
TH
RY
VE
! !
C H
MU
03/18/2021