KeyListener in Java Program
KeyListener in Java Program
import java.applet.*;
import java.awt.event.*;
public class siva extends Applet implements keylistener
{
String msg="";
int x=10,y=20;
public void init()
{
addKeyListener(this);
}
public void KeyPressed(KeyEvent ke)
{
showStatus("Keydown");
}
public void KeyReleased(KeyEvent ke)
{
showStatus("Key up");
}
public void KeyTyped(KeyEvent ke)
{
msg+=ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg x,y);
}
}
//<applet code="siva.class" width=300 height=300></applet>
0 coment�rios:
Post a Comment