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.RobotNew 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:
- Accessibility enabled applications will be able to give more feedback. For example, if the user acts on a screen object using voice commands, the mouse pointer can be moved to indicated the object being manipulated.
- Enables the creation of computer-based training (CBT) and other demo type Java applications.
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.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.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.AncestorEventThe new classes and interfaces implementing the new event types are:
- displayability - whether a component has a peer
- show state - whether a component is showing on the screen
- ancestors additions to and deletions from the hieracrhy
- ancestor resizes
- ancestor moves
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:
- java.awt.event.HierarchyEvent
- java.awt.event.HierarchyListener
- java.awt.event.HierarchyBoundsListener
- java.awt.event.HierarchyBoundsAdapter
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:
Header files associated with the AWT Native Interface are in the SDK's include directory. They are
- Define a class that extends a Canvas .
- Declare the paint method as native and load its shared library in the static block.
- Use javah to generate a C/C++ header file for the native paint method. (See javah documentation for Win32 and Solaris platforms.)
- Write the native paint method and build it as a shared library.
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.
- include/jawt.h on both Win32 and SolarisTM platforms
- include/win32/jawt_md.h in the Win32 SDK only
- include/solaris/jawt_md.h on Solaris SDK only
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 |