import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Kodutoo extends Frame implements ActionListener{ int a, b, c, d, e, f, g, h, i; TextField tf1=new TextField(a); TextField tf2=new TextField(b); TextField tf3=new TextField(c); TextField tf4=new TextField(d); TextField tf5=new TextField(e); TextField tf6=new TextField(f); TextField tf7=new TextField(g); TextField tf8=new TextField(h); TextField tf9=new TextField(i); Button nupp=new Button(" OK "); public Kodutoo(){ setLayout(new FlowLayout()); setSize(600, 300); Panel p1=new Panel(new GridLayout(3, 3)); p1.add(tf1); p1.add(tf2); p1.add(tf3); p1.add(tf4); p1.add(tf5); p1.add(tf6); p1.add(tf7); p1.add(tf8); p1.add(tf9); add(p1); add(nupp) ; nupp.addActionListener(this); setVisible(true); } public static void main(String argumendid[]){ new Kodutoo(); } public void paint(Graphics ekraan){ a=(int)(10*Math.random()); e=(int)(10*Math.random()); i=(int)(10*Math.random()); tf1.setText(a+""); tf5.setText(e+""); tf9.setText(i+""); } public void actionPerformed(ActionEvent ev){ Graphics ekraan=this.getGraphics(); a=Integer.parseInt(tf1.getText() .trim()); b=Integer.parseInt(tf2.getText() .trim()); c=Integer.parseInt(tf3.getText() .trim()); d=Integer.parseInt(tf4.getText() .trim()); e=Integer.parseInt(tf5.getText() .trim()); f=Integer.parseInt(tf6.getText() .trim()); g=Integer.parseInt(tf7.getText() .trim()); h=Integer.parseInt(tf8.getText() .trim()); i=Integer.parseInt(tf9.getText() .trim()); System.out.println(a+e+i); int sum=a+b+c; if ( (sum == d+e+f) && (sum == g+h+i) && (sum == a+d+g) && (sum == b+e+h) && (sum == c+f+i) && (sum == a+e+i)){ ekraan.drawString("TUBLI!",550, 250); }else{ ekraan.drawString("VALE!",550, 250); } } }