import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class Klahvikuular extends Applet implements KeyListener{ int x = (int)(Math.random()*300); int y = (int)(Math.random()*300); String taht = ""+(char)((int)(Math.random()*27)+'a'); public void init(){ addKeyListener(this); } public void paint(Graphics g){ g.drawString(taht,x,y); } public void keyPressed(KeyEvent e){ System.out.println("Klahv alla "+e.getKeyChar()); if(e.getKeyChar() == taht.charAt(0)){ Graphics g = getGraphics(); g.setColor(Color.white); g.drawString(taht,x,y); } } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} }