Wednesday, February 11, 2009

Applet Challenge: Letters

The below hyperlinks provide the sample for the mouse click and drag of a ball:
The Challenge:
Using the sample given above and the example for KeyListener on page 152 of your notes, create a click and drag of typed letters. An example is given in the link below:
Note: You have to click once on the applet area first, then type a letter. You can assume that the default letter is 'A'. Below is some code to help you out:

// Assuming z is a String variable declared
// in the class:

public void keyTyped(KeyEvent e) {
z = "" + e.getKeyChar();
repaint();
}

No comments:

Post a Comment