import java.awt.*; import java.applet.*; import java.awt.event.*; public class Liitmine extends Applet implements ActionListener{ TextField text1=new TextField(20); TextField text2=new TextField(20); TextField res=new TextField(14); Button button=new Button("Liita"); public Liitmine(){ add(text1); add(text2); add(res); add(button); text1.addActionListener(this); text2.addActionListener(this); res.addActionListener(this); button.addActionListener(this); } public void actionPerformed(ActionEvent a_e) { String act = a_e.getActionCommand(); if (act.equals("Liita")) { double a = Double.valueOf(text1.getText()).doubleValue(); double b = Double.valueOf(text2.getText()).doubleValue(); double c = a + b; res.setText(String.valueOf(c)); } } public static void main(String[] argumendid){ Frame f=new Frame("Ratsionaalarvude liitmine"); f.add(new Liitmine()); f.setSize(300, 300); f.setVisible(true); } }