CS 696 Emerging Technologies: Java Distributed Computing Spring Semester, 1999 Remote AWT |
||
---|---|---|
© 1999, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 01-Feb-99 |
Remote AWT (RAWT)
RAWT
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 |
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
ToolKit myToolKit = Toolkit.getDefaultToolkit(); peer = myToolKit.createButton(this);(Note: this code is a simplified version of what actually happens)
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
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
RAWT Components
Server
java com.ibm.rawt.server.RAWTPCServer
java -Dawt.toolkit=com.ibm.rawt.client.CToolkit -DRmtAwtServer=ServerIP ApplicationMainClass