import java.awt.*; import java.awt.event.*; public class Ralliklient1 extends Panel implements KeyListener{ JututoaKlient2 jk=new JututoaKlient2(); Soiduala1 sa=new Soiduala1(); public Ralliklient1(){ setLayout(new GridLayout(2, 1)); add(sa); add(jk); jk.soiduala=sa; sa.addKeyListener(this); } public void keyPressed(KeyEvent e){ if(e.getKeyCode()==KeyEvent.VK_LEFT){ jk.vorku.println(".vasakule"); } if(e.getKeyCode()==KeyEvent.VK_RIGHT){ jk.vorku.println(".paremale"); } if(e.getKeyCode()==KeyEvent.VK_UP){ jk.vorku.println(".kiiremaks"); } if(e.getKeyCode()==KeyEvent.VK_DOWN){ jk.vorku.println(".aeglasemaks"); } } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} public static void main(String[] arg){ Frame f=new Frame("Ralli"); f.add(new Ralliklient1()); f.setSize(300, 600); f.setVisible(true); } }