import java.awt.*; import java.awt.event.*; public class MasinaYhendaja2 extends java.applet.Applet implements AdjustmentListener, ActionListener{ Hakklihamasin2 h = new Hakklihamasin2(); Scrollbar sb=new Scrollbar(Scrollbar.VERTICAL, 5, 2, 2, 20); //suund, alg, nupusuurus, vähim, suurim TextField tf=new TextField(); public MasinaYhendaja2(){ setLayout(new BorderLayout()); add(sb, BorderLayout.WEST); add(tf, BorderLayout.NORTH); add(h, BorderLayout.CENTER); sb.addAdjustmentListener(this); tf.addActionListener(this); } public void adjustmentValueChanged(AdjustmentEvent e){ h.aukudeArv(e.getValue()); tf.setText(e.getValue()+""); } public void actionPerformed(ActionEvent e){ h.aukudeArv(Integer.parseInt(tf.getText().trim())); sb.setValue(Integer.parseInt(tf.getText().trim())); } }