Java Swing Tutorials - Herong's Tutorial Examples
∟AWT (Abstract Windows Toolkit)
∟What Is AWT (Abstract Windows Toolkit)
This section describes what is AWT (Abstract Windows Toolkit) - A Java package, java.awt.* that allows Java applications to operate graphical devices and create GUI (Graphical User Interfaces).
What Is AWT (Abstract Windows Toolkit)?
AWT is a Java package, java.awt.* that allows Java applications to operate graphical devices and create
GUI (Graphical User Interfaces).
The JDK documentation offers another description of AWT:
"AWT contains all of the classes for creating user interfaces and for painting graphics and
images. A user interface object such as a button or a scrollbar is called, in AWT
terminology, a component. The Component class is the root of all AWT components. See
Component for a detailed description of properties that all AWT components share."
The AWT package, java.awt.* was introduced in JDK 1.0.
Later in JDK 1.2, the Swing package, javax.swing.*, was introduced to provide
a richer API and hiding AWT behind a wrapper layer.
The AWT package contains following major class:
- java.awt.AWTEvent - The root class of all SWT event classes.
- java.awt.Button - Represents a labeled button.
- java.awt.Canvas - Represents a blank rectangular area of
the screen onto which the application can draw or from which the application can trap
input events from the user.
- java.awt.Checkbox - Represents a graphical component
with either an "on" (true) or "off" (false) state.
- java.awt.Color - Encapsulates colors in the default sRGB color space.
- java.awt.Component - A graphical representation that can be displayed on the screen
and that can interact with the user.
- java.awt.Container - A logical component that can hold other components as a group.
- java.awt.Desktop - Allows the application to interact with various desktop capabilities.
- java.awt.Dialog - Represents a top-level window with a title and a border
that is typically used to take some form of input from the user.
- java.awt.Event - Represents a labeled button.
- java.awt.FlowLayout - Arranges components in a directional flow, much like lines of text in a paragraph.
- java.awt.Font - Represents fonts, which are used to render text in a visible way.
- java.awt.Frame - Represents a top-level window with a title and a border.
- java.awt.Graphics - An abstract base class for all graphics contexts that allow an
application to draw onto components that are realized on various devices, as well as onto
off-screen images.
- java.awt.GraphicsEnvironment - Describes the collection of GraphicsDevice objects
and Font objects available to a Java(tm) application on a particular platform.
- java.awt.GridBagLayout - A flexible layout manager that aligns components
vertically, horizontally or along their baseline without requiring that the components be
of the same size.
- java.awt.GridLayout - A layout manager that lays out a container's components in a rectangular grid.
- java.awt.Image - An abstract class acting as the superclass of all classes that represent graphical images.
- java.awt.Label - A component for placing text in a container.
- java.awt.List - A component presenting the user with a scrolling list of text items.
- java.awt.Menu - A pull-down menu component that is deployed from a menu bar.
- java.awt.MenuBar - Encapsulates the platform's concept of a menu bar bound to a frame.
- java.awt.MenuItem - An item associated to the MenuBar.
- java.awt.MouseInfo - Provides methods for getting information about the mouse, such as
mouse pointer location and the number of mouse buttons.
- java.awt.Panel - The simplest container class.
- java.awt.Point - Represents a location in (x,y) coordinate space, specified in integer precision.
- java.awt.Polygon - Encapsulates a description of a closed, two-dimensional region within a coordinate space.
- java.awt.Rectangle - Specifies an area in a coordinate space that is enclosed by the
Rectangle object's upper-left point (x,y) in the coordinate space, its width, and its
height.
- java.awt.Robot - Generates native system input events for the purposes
of test automation, self-running demos, and other applications where control of the mouse
and keyboard is needed.
- java.awt.Scrollbar - Embodies a scroll bar, a familiar user-interface object.
- java.awt. ScrollPane - A container class which implements automatic horizontal
and/or vertical scrolling for a single child component.
- java.awt.SystemTray - Represents the system tray for a desktop.
- java.awt.Taskbar - Allows a Java application to interact with the system task area (taskbar, Dock, etc.).
- java.awt.TextArea - A multi-line region that displays text.
- java.awt.TextField - A text component that allows for the editing of a single line of text.
- java.awt.Toolkit - The abstract superclass of all actual implementations of the Abstract Window Toolkit.
- java.awt.TrayIcon - Represents a tray icon that can be added to the system tray.
- java.awt.Window object - A top-level window with no borders and no menubar.
Table of Contents
About This Book
JDK (Java Development Kit)
Introduction of Java Swing Package
Graphics Environment of the Local System
JFrame - Main Frame Class
JLabel - Swing Label Class
JButton - Swing Button Class
JCheckBox - Swing Check Box Class
JRadioButton - Swing Radio Button Class
JTextField - Swing Text Field Class
JComboBox - Swing Combo Box Class
Menu Bar, Menus, Menu Items and Listeners
Creating Internal Frames inside the Main Frame
Layout of Components in a Container
LookAndFeel and UIManager
Option Dialog Boxes
JEditorPane - The Editor Pane Class
SwingWorker - The Background Task Worker
►AWT (Abstract Windows Toolkit)
►What Is AWT (Abstract Windows Toolkit)
HelloAWT.java - My First AWT Program
Closing AWT Frame and Terminating Application
Drawing Graphics - Using paint() on Frame or Component
Creating Labels with java.awt.Label Class
Creating Buttons with java.awt.Button Class
AWT Button Action Handler at the Component Level
AWT Button Action Handler at the Frame Level
AWT Button Mouse Click Handler at the Frame Level
AWT TextField and ActionListener
MenuBarTest.java - AWT Menu Bar Test Program
MenuTest.java - AWT Menu Test Program
MenuItemTest.java - AWT Menu Item Test Program
MenuItemActionListenerTest.java - AWT Menu Item Action Listener
Integration with Desktop System
Archived Tutorials
References
Full Version in PDF/EPUB