main() method defines the main entry point for our application.
public static void main(String args)
The default constructor,
Scribble, initializes the member variables, clears the screen, and draws the initial frame.
paint() method is responsible for updating or redrawing the display. It makes use of the class variable
g -- a
Graphics object similar to the one used in the Java 2 AWT.
private void paint()
penDown() method implements the event handler to handle the event of putting the stylus, or pen, on the screen. It passes in the X and Y coordinates. In our Scribble application, this method tests to see if either the Clear or Exit button was pressed and if so, handles those events.
public void penDown(int x, int y)
keyDown() method handles entering a graffiti letter on the graffiti writing area on your Palm device. The integer value,
keyCode, passed into this method is the value of the character key entered. In the Scribble application we store the key pressed in the
lastKey member variable then invoke the
paint() method to update the screen.
public void keyDown(int keyCode)
penMove() method handles the event of dragging the stylus across the screen. In the Scribble application, it is responsible for drawing with the stylus.
public void penMove(int x, int y)
The last method used,
clearDrawingArea(), is the method invoked by the
penDown event handler when the user taps the Clear button. It is a private method because it is intended only to be used internally within the
private void clearDrawingArea()