import javax.swing.*; import java.awt.*; import java.awt.event.*; public class IndikaatoriProov extends JApplet implements ActionListener, ProtsendiKuular{ Indikaator idk1=new Indikaator(30); Indikaator idk2=new Indikaator(60); TextField tf1=new TextField(); TextField tf2=new TextField(); public IndikaatoriProov(){ setLayout(new GridLayout(2, 2)); add(idk1); add(idk2); add(tf1); add(tf2); tf1.addActionListener(this); tf2.addActionListener(this); idk1.lisaProtsendiKuular(this); } public void protsentMuutus(Object allikas, double uusProtsent){ if(allikas==idk1){ tf1.setText(String.valueOf(uusProtsent)); } } public void actionPerformed(ActionEvent e){ if(e.getSource()==tf1){ idk1.muudaProtsent(Double.parseDouble(tf1.getText())); } if(e.getSource()==tf2){ idk2.muudaProtsent(Double.parseDouble(tf2.getText())); } } public static void main(String arg[]){ JFrame f=new JFrame("Katsetused"); f.add(new IndikaatoriProov()); f.setSize(300, 300); f.setVisible(true); } }