applet that does not print

A

ananttickoo

hi
i was writing a applet that would take my key hit as input and print
it. but its not doing so. i can't find the bug. help me




Code:
import java.awt.event.*;
import java.applet.*;
import java.awt.*;
import java.lang.*;

public class buggy2 extends Applet
implements KeyListener
{
String msg="foo bar";

public void paint(Graphics g)
{
g.drawString(msg,0,10);
g.drawString(msg,10,10);
}

public void inti()
{
addKeyListener(this);
requestFocus();

}

public void keyReleased(KeyEvent ke)
{
msg="hmmmmmm.";
repaint();
}

public void keyPressed(KeyEvent ke)
{
msg="type it";
repaint();
}


public void keyTyped(KeyEvent ke)
{
msg+=ke.getKeyChar();
repaint();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top