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();
}
}
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();
}
}