import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Liida1 extends Applet implements ActionListener{ TextField liidetav1=new TextField(5), liidetav2=new TextField(5), summa=new TextField(5); Label pluss=new Label("+", Label.CENTER); Button vordub=new Button("="); public void init(){ setLayout(new GridLayout(1, 5)); add(liidetav1); add(pluss); add(liidetav2); add(vordub); add(summa); vordub.addActionListener(this); } public void actionPerformed(ActionEvent e){ summa.setText(numbriks(liidetav1)+numbriks(liidetav2)+""); } int numbriks(TextField tf){ return Integer.parseInt(tf.getText().trim()); } }