SWING and AWT - Best Practice

Target Audience: CAST Administrators

Summary: This document provides a guide based on CAST’s field experience on how to configure Swing and AWT based applications using CAST AIP. These configurations are used all versions of CAST AIP 8.2.x and above for Swing and AWT offering (see Reference Materials below for links) to overcome limitations such as missing links. The applicability of this guide should have assessed for newer versions of CAST AIP and Extension.

Introduction to Swing and AWT

This section gives a brief overview of the framework.

Abstract Window Toolkit (AWT) is Java’s original platform-dependent windowing, graphics, and user-interface widget toolkit. From first release of Sun Microsystems Java in 1995, AWT.

    1. Java 1.0 & Java 1.1 - These features are provided by the Abstract Windowing Toolkit (AWT).  Java 2D
    2. Java 1.2                 - JFC were introduced. Printing capability.
    3. Java 2.0                 - Swing is a core part for this release.

AWT existed before JFC. AWT was heavily criticized for being little more than a wrapper around the native graphical capabilities of the host platform.
An alternative graphics library called the Internet Foundation Classes was developed in more platform-independent code by Netscape.
Same time, another graphics library, called Application Foundation Classes (AFC), was developed independently by Microsoft. It was made to be easier to extend the graphic components, but was primarily aimed for use with the Microsoft Java Virtual Machine.
On April 2, 1997, Sun Microsystems and Netscape announced their intention to combine IFC with other technologies to form the “Java Foundation Classes”.[1] It is later renamed to “Swing”, adding the capability for a pluggable look and feel of the widgets.

Versions of Swing and AWT supported by CAST

This section highlights the Swing and AWT versions supported by CAST AIP 8.2.x.

File Types expected for Swing and AWT

This section highlights all the file types that can be expected to be delivered if the application has implemented this framework.

  • Java (Standalone Swing and AWT)

    • .java
  • Web based solution :

Swing and AWT - JFC Hierarchy & Classifications

How to identify the implementation of Swing and AWT

This section details the approach for identifying the presence of Swing and AWT in the code delivered.

ComponentEvent handlerListenerMethodsAdapters
Button List MenuItem TextFieldactionPerformed(E)ActionListeneraddActionListener( )ActionAdapter
FramewindowActivated(E) windowClosed(E) windowClosing(E) windowDeactivated(E) windowDeiconified(E) windowIconified(E)WindowListeneraddWindowListener( )WindowAdapter
Frame PanelconponentAdded(E) conponentRemoved(E)ContainerListeneraddContainerListener( )ContainerAdapter
ScrollbaradjustmentValueChanged(E)AdjustmentListeneraddAdjustmentListener( )
Button / Key Canvas PanelkeyPressed(E) keyReleased(E) keyTyped(E)KeyListeneraddKeyListener( )KeyAdapter
Button / Mouse Canvas PanelmouseClicked(E) mouseEntered(E) mouseExited(E) mousePressed(E) mouseReleased(E)MouseListeneraddMouseListener( )MouseAdapter
Button / Mouse Canvas PanelmouseDragged(E) mouseMoved(E)MouseMotionListeneraddMouseMotionListener( )MouseMotionAdapter
TextComponenttextValueChanged(E)TextListeneraddTextListener( )

Swing and AWT Description

This section gives a brief overview of Swing and AWT.

The Java Foundation Classes (JFC) are a comprehensive set of GUI components and services which dramatically simplify the development and deployment of commercial-quality desktop and Internet/Intranet applications.

  • Swing is the project code name for the lightweight GUI components in JFC.
  • Accessibility API enables Java applications to work with alternate input and output devices such as Screen Readers, Screen Magnifiers, Braille terminals, and others.
  • Java 2D, developers can render, manipulate, and transform complex 2D images and text. Java 2D enables the creation of richer-looking components and applications.

Drag & Drop - Supports dragging and dropping of objects between java program or non-java programs.

Standard flow:

CAST View

Event Hierarchy:

How to configure Swing and AWT in CAST AIP

This section describes all the CAST configuration steps to be followed in order to configure Swing and AWT based application.

Server Manager Configuration

N/A

Pre Analysis Configuration

N/A

Enlighten

This section gives an overview of the Enlighten diagram.

  • Sample #1

  • Sample #2

CMS Configuration

N/A

TCC Configuration

References

TopicLink
Java Foundation Classeshttps://en.wikipedia.org/wiki/Java_Foundation_Classes
Listeners vs Adaptershttps://blogs.oracle.com/corejavatechtips/listeners-vs-adapters
AWT Events in Javahttps://way2java.com/awt-events/java-made-clear-difference-between-listener-and-adapter/
Swing Components and Containershttp://www.studytonight.com/java/java-swing-components.php
Java Swing Tutorial for beginnershttp://beginnersbook.com/2015/07/java-swing-tutorial/
Trail: Creating a GUI With JFC/Swinghttps://docs.oracle.com/javase/tutorial/uiswing/
Java Swing Tutorialhttps://www.javatpoint.com/java-swing
Java AWT Tutorialhttps://www.javatpoint.com/java-awt
Java Adapter Classeshttps://www.javatpoint.com/java-adapter-classes
Introducing Swinghttps://www.safaribooksonline.com/library/view/java-swing/156592455X/ch01.html
Introducing Swing and the JFChttp://javadevwannabe.blogspot.in/2012/02/introducing-swing-and-jfc.html
Event Handling in JDK 1.1, Scrollbar (Adjustment) Eventshttp://www.dickbaldwin.com/java/Java090.htm