kAWT Porting Quick Guide

kAWT is a plain software implementation of an AWT subset suitable for PDAs and embedded devices. In order to port kAWT to a new Java platform, only very few abstract methods must be implemented in four implementation classes:

As soon as any kAWT component is accessed, by the application, the component tries to find the implementation classes by reading the package name from the system variable

de.kawt.classbase

Then, the ToolkitImpl class is instantiated by calling

Class.forName (classbase+".ToolkitImpl").newInstance ();

Thus, ToolkitImpl must provide a public constructor without parameters. In the public constructor, ToolkitImpl should set up the event handler: For all input events, a corresponding AWTEvent subclass must be instantiated and delivered to the system event queue by calling

Toolkit.getDefaultToolkit ().geSystemEventQueue ().postEvent (...)

Please note: The Event Source of the events can be determined using the helper classes in the package de.kawt.impl.

The following table shows a complete list of methods that need to be implemented for porting kAWT. The packages java.awt.impl.rim, java.awt.impl.kjava and java.awt.impl.midp contain existing kAWT ports for RIM, Kjava and MIDP and can be used as guidance for custom ports.

Class Remarks / Methods
public class ToolkitImpl extends de.kawt.KawtToolkit

The public constructor is called at kAWT initialization. The implementation can set up event handling there.

The sync method provides a repaint callback hook for the implementation. If the device has a buffered screen memory, an update should be triggered when this method is called. Can be ignored by most implementations.

public void beep ()
public FontMetrics getFontMetrics (Font font)
public Dimension getScreenSize ()
public Image createImage (byte [] data)
public void sync ()
public class GraphicsImpl extends java.awt.Graphics
public GraphicsImpl ()
public void clipRect (int x, int y, int w, int h)
public void setClip (int x, int y, int w, int h)
public void clearRect (int x, int y, int w, int h)
public boolean drawImage (Image image, int x, int y, 
			  ImageObserver observer)
public void drawLine (int x1, int y1, int x2, int y2)
public void drawPolyline (int[] xPoints, int[] yPoints, 
                          int nPoints)
public void drawRoundRect (int x, int y, int width, int height, 
	               	   int arcWidth, int arcHeight)
public void drawString (String text, int x, int y) 
public void drawOval (int x, int y, int w, int h)
public void drawRect (int x,  int y, int width, int height)
public void fillRect (int x, int y, int width, int height)
public void fillRoundRect (int x, int y, 
                           int width, int height, 
			   int arcWidth, int arcHeight)
public Color getColor ()
public Font getFont ()
public Rectangle getClipBounds ()
public Rectangle getClipBounds (Rectangle r)
public boolean hitClip (int x, int y, int w, int h)
public FontMetrics getFontMetrics () 
public FontMetrics getFontMetrics (Font font)
public void setColor (Color c)
public void setFont (Font font)
public void translate (int x, int y) 
public class FontMetricsImpl extends java.awt.FontMetrics
public int stringWidth (String s) {
public int getHeight ()
public int getAscent ()
public int getDescent () 
public int getLeading ()
public class ImageImpl extends java.awt.Image
public int getWidth (ImageObserver o) {
public int getHeight (ImageObserver o) {