SDSU CS 696 Emerging Technologies: Java Distributed Computing
Spring Semester, 1999
Remote AWT
Previous    Lecture Notes Index    Next    
© 1999, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 01-Feb-99

Contents of Doc 3, Remote AWT


References

Remote AWT (RAWT) for Java documentation

You can learn more about RAWT and download it at:
http://www.alphaWorks.ibm.com/formula.nsf/system/technologies/51A3BC3A88D2B00A882565CE007F61F5?OpenDocument

Design Patterns: Elements of Reusable Object-Oriented Software , Gamma, Helm, Johnson, Vlissides, 1995, Abstract Factory pp. 87-96, Singleton pp. 127-134, Bridge pp.151-162.

Doc 3, Remote AWT Slide # 2
Remote AWT (RAWT)

RAWT
Runs Java AWT programs across any TCP/IP network
Does not use X windows
AWT programs run remotely without any modification
Does support Swing, but is not optimized for Swing
Uses JDK 1.1.6 or JDK 1.1.7
Will be converted to JDK 1.2 & optimized for Swing
Developed at IBM, available from alphaworks ( http://www.alphaWorks.ibm.com )


Doc 3, Remote AWT Slide # 3

How does RAWT work

Background

Peers

All AWT components use peers

The peer does the platform specific operations for the component, including drawing on the screen

Each component has its own type of peer

The java.awt.peer package (JDK1.2)contains the following peer interfaces:

ButtonPeer.java
CanvasPeer.java
CheckboxMenuItemPeer.java
CheckboxPeer.java
ChoicePeer.java
ComponentPeer.java
ContainerPeer.java
DialogPeer.java
FileDialogPeer.java
FontPeer.java
FramePeer.java
LabelPeer.java
LightweightPeer.java
ListPeer.java
MenuBarPeer.java
MenuComponentPeer.java
MenuItemPeer.java
MenuPeer.java
PanelPeer.java
PopupMenuPeer.java
ScrollbarPeer.java
ScrollPanePeer.java
TextAreaPeer.java
TextComponentPeer.java
TextFieldPeer.java
WindowPeer.java

(Note: the java.awt.peer package does not appear in the standard on-line Java API documentation)

Swing components also use “basic” peers to perform low-level operations


Doc 3, Remote AWT Slide # 4
ToolKit

Each platform contains classes that implement each of the peer interfaces in the java.awt.peer package

These peer implementations do use native code

java.awt.ToolKit
Is an abstract class
Defines methods to create any peer
Each JVM uses a concrete subclass of ToolKit to create peers

All AWT/Swing components create peers using the Toolkit

The code used by the Button class to get its peer reduces to:

   ToolKit myToolKit = Toolkit.getDefaultToolkit();
   peer = myToolKit.createButton(this);
(Note: this code is a simplified version of what actually happens)


Doc 3, Remote AWT Slide # 5
Changing the Default ToolKit

The name of the class used for the ToolKit implementation is a system property.

The following code will print out the name of the class being used as the ToolKit implementation:

   System.out.println( System.getProperty( "awt.toolkit" ));

The following code will print out all current system property keys:

Enumeration systemPropertyKeys = System.getProperties().propertyNames();

while ( systemPropertyKeys.hasMoreElements() )
System.out.println( systemPropertyKeys.nextElement() );

The –D flag of the command java sets system properties

The following code will set system property “awt.toolkit” to edu.sdsu.whitney.SimpleToolKit when running the program foo

java -Dawt.toolkit=edu.sdsu.whitney.SimpleToolKit  foo

Doc 3, Remote AWT Slide # 6
AWT and Design Patterns

For those that know about design patterns

AWT Peers are an example of the use of the Bridge pattern

The Singleton pattern is used to insure there is only one default ToolKit. Toolkit.getDefaultToolkit() returns the singleton

The ToolKit class is an example of the Abstract Factory pattern, which is sometimes called a Kit

Doc 3, Remote AWT Slide # 7

RAWT Components

Server
Server code
Component Classes which send responses back to client
Client
Peer implementations
Code to talk to server

Protocol
Client & Server need to agree on how to create AWT components and send AWT events to each other



Start server on machine to display application GUI

   java com.ibm.rawt.server.RAWTPCServer

Start application on client machine using:

   java -Dawt.toolkit=com.ibm.rawt.client.CToolkit -DRmtAwtServer=ServerIP ApplicationMainClass


Copyright ©, All rights reserved.
1999 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

Previous    visitors since 01-Feb-99    Next