import java.io.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Lift extends Applet implements ActionListener{ int lift1=(int) (9*Math.random())+1; int lift2=(int) (9*Math.random())+1; Button nupp1 = new Button("1"); Button nupp2 = new Button("2"); Button nupp3 = new Button("3"); Button nupp4 = new Button("4"); Button nupp5 = new Button("5"); Button nupp6 = new Button("6"); Button nupp7 = new Button("7"); Button nupp8 = new Button("8"); Button nupp9 = new Button("9"); public Lift(){ Panel nupupaneel = new Panel(new GridLayout(9, 1)); nupupaneel.add(nupp9); nupupaneel.add(nupp8); nupupaneel.add(nupp7); nupupaneel.add(nupp6); nupupaneel.add(nupp5); nupupaneel.add(nupp4); nupupaneel.add(nupp3); nupupaneel.add(nupp2); nupupaneel.add(nupp1); nupp1.addActionListener(this); nupp2.addActionListener(this); nupp3.addActionListener(this); nupp4.addActionListener(this); nupp5.addActionListener(this); nupp6.addActionListener(this); nupp7.addActionListener(this); nupp8.addActionListener(this); nupp9.addActionListener(this); setLayout(new BorderLayout()); add(nupupaneel, BorderLayout.EAST); } public void paint(Graphics g){ for (int nr=0; nr<=360; nr=nr+40){ g.drawRect(0, nr-40, 20, nr); } for (int nr=0; nr<=360; nr=nr+40){ g.drawRect(20, nr-40, 20, nr); } g.fillRect(0,(9-lift1)*40, 20, 40); g.fillRect(20,(9-lift2)*40, 20, 40); } public void actionPerformed(ActionEvent e){ if(e.getSource() == nupp9) Kutsu(9); if(e.getSource() == nupp8) Kutsu(8); if(e.getSource() == nupp7) Kutsu(7); if(e.getSource() == nupp6) Kutsu(6); if(e.getSource() == nupp5) Kutsu(5); if(e.getSource() == nupp4) Kutsu(4); if(e.getSource() == nupp3) Kutsu(3); if(e.getSource() == nupp2) Kutsu(2); if(e.getSource() == nupp1) Kutsu(1); } public void Kutsu(int korrus) { if(Math.abs(lift2-korrus)