import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Exam extends Applet implements ActionListener{ int nr1=0; int nr2=0; TextField tf=new TextField("0"); TextField tx=new TextField("0"); public Exam(){ add(tf); add(tx); tf.addActionListener(this); tx.addActionListener(this); } public void actionPerformed(ActionEvent e){ nr1=Integer.parseInt(tf.getText().trim()); nr2=Integer.parseInt(tx.getText().trim()); repaint(); } public void paint(Graphics g){ int a=nr1*nr2; g.setColor(Color.red); g.drawString("vastus="+a, 75, 75); } public static void main(String argumendid[]){ Frame f=new Frame("Kirjalik Korrutamine"); f.setSize(300, 300); f.add(new Exam()); f.setVisible(true); } }