//Koostanud Renee Pajuste import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class liitmine extends Applet implements ActionListener{ TextField arv1=new TextField(5), arv2=new TextField(5), vastus=new TextField(5); Label pluss=new Label("+", Label.CENTER); Button vordub=new Button("="); Button Clear=new Button("Clear"); public void init(){ setLayout(new GridLayout(1, 6)); add(arv1); arv1.setFont(new Font("Courier", Font.PLAIN, 25)); add(pluss); add(arv2); arv2.setFont(new Font("Courier", Font.PLAIN, 25)); add(vordub); add(vastus); vastus.setFont(new Font("Courier", Font.PLAIN, 20)); add(Clear); vordub.addActionListener(this); Clear.addActionListener(this); } public void actionPerformed(ActionEvent e){ if(e.getSource()==vordub){ vastus.setText(numbriks(arv1)+numbriks(arv2)+""); }else { vastus.setText(""); arv2.setText(""); arv1.setText(""); } } /* int nr1=Integer.parseInt(arv1.getText().trim()); int nr2=Integer.parseInt(arv2.getText().trim()); */ int numbriks(TextField tf){ return Integer.parseInt(tf.getText().trim()); } }