import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Bassein extends Applet implements ActionListener{ int nr=100; int nr1=25; int nr2=50; int nr3=20000; int nr4=0; int nr5=0; int nr6=0; TextField tf=new TextField("100"); TextField tf1=new TextField("25"); TextField tf2=new TextField("50"); TextField tf3=new TextField("20000"); TextField tf4=new TextField("Praegu on basseinis parasjagu vett;"); public Bassein(){ add(tf); add(tf1); add(tf2); add(tf3); add(tf4); tf.addActionListener(this); tf1.addActionListener(this); tf2.addActionListener(this); tf3.addActionListener(this); tf4.addActionListener(this); } public void actionPerformed(ActionEvent e){ nr=Integer.parseInt(tf.getText()); nr1=Integer.parseInt(tf1.getText()); nr2=Integer.parseInt(tf2.getText()); nr3=Integer.parseInt(tf3.getText()); repaint(); } public void paint(Graphics g){ nr4=nr3/(nr*nr1); nr6=nr*nr1*nr2; System.out.println(nr3); System.out.println(nr6); if(nr3>nr6){ if(nr3>nr6){ tf4.setText("Nyyd ajab juba yle ääre!!!"); }else{ tf4.setText("Praegu on basseinis parasjagu vett"); } }else{ if(nr3<1){ tf4.setText("Nyyd on vesi otsas!!!"); }else{ tf4.setText("Praegu on basseinis parasjagu vesi"); } } nr5=nr2-nr4; g.drawRect(50, 100, nr, nr2); g.setColor(Color.blue); g.fillRect(50, 100+nr5, nr, nr4); } public static void main(String argumendid[]){ Frame f=new Frame(""); f.setSize(300, 300); f.add(new Bassein()); f.setVisible(true); } }