Java

AWT Enhancements in the JavaTM 2 SDK, v1.3

Documentation Contents
Version 1.3 of the Java 2 SDK includes the following AWT enhancements:
New Class java.awt.Robot
New Event Masks for PaintEvents and InvocationEvents
Paint Coalescing
Printing API Enhancements
New Event Type for Tracking Changes to Component Hierarchies
AWT Native Interface

New Class java.awt.Robot
New class java.awt.Robot has been added to the JavaTM 2 Platform. The Robot API is designed to make automated AWT and Swing testing possible. The Robot API allows code written in the Java programming language to generate low-level native mouse and keyboard input events. Because the events are generated at the operating system level (as opposed to the Java event queue or component level), they are indistinguishable from real user input to the rest of the AWT (both the native and Java-language portions).

Though designed to improve testability, the Robot API also provides other benefits:

New Event Masks for PaintEvents and InvocationEvents

The new final static fields PAINT_EVENT_MASK and INVOCATION_EVENT_MASK have been added to class AWTEvent. These fields are now available for use by addAWTEventListener() to allow client applications to listen for paint events and invocation events.

Paint Coalescing

Painting performance has been enhanced through the implementation of paint coalescing. Areas that require repainting are now coalesced into a single, non-rectangular repaint area as they are posted to the event queue. This has the effect of batching repaints, executing multiple repaints simultaneously. Previously, paint events were queued up and executed in succession, even when the repaint areas overlapped.

Printing API Enhancements

Two new classes have been added to package java.awt.print: Class JobAttributes controls properties of a print job such as destination, number of copies, page ranges, etc. Class PageAttributes controls attributes of a printed page such as paper size, orientation, print quality, etc.

These classes are used by a new method in class java.awt.Toolkit:

getPrintJob(Frame, String, JobAttributes, PageAttributes)
See Java AWT: Printing for more information on the printing API.

Support for using attributes will be added to the printing API in a future release of the Java platform.

New Event Type for Tracking Changes to Component Hierarchies

Several new classes have been added to the Java 2 Platform to provide a standardized way for components to track changes to their component hierarchy. The new API is a preferred alternative to that provided by javax.swing.event.AncestorEvent The new classes and interfaces implementing the new event types are: The following methods have been added to java.awt.Component: The following fields have been added to java.awt.AWTEvent: Class java.awt.AWTEventMulticaster now implements interfaces HierarchyListener and HierarchyBoundsListener. In addition, it has the following new methods:

AWT Native Interface

The AWT Native Interface is a new interface for integrating native rendering engines with the Java 2 platform. The AWT Native Interface lets you design UIs with natively rendered components for best rendering performance.

In the most common usage, four steps are involved:

  1. Define a class that extends a Canvas .
  2. Declare the paint method as native and load its shared library in the static block.
  3. Use javah to generate a C/C++ header file for the native paint method. (See javah documentation for Win32 and Solaris platforms.)
  4. Write the native paint method and build it as a shared library.
Header files associated with the AWT Native Interface are in the SDK's include directory. They are These headers are not part of the official specification of the Java 2 Platform. The headers are provided as a convenience to developers who want a standardized way to access native drawing functionality.

For further information and sample code, see The AWT Native Interface.


Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.


Please send comments to: java-awt@java.sun.com
Sun