import java.awt.*; import java.applet.*; import java.awt.event.*; import java.io.*; import java.lang.*; public class Ring extends Applet implements ActionListener{ TextField tf3=new TextField(10); int keskx=150; int kesky=100; int x=20; int y=20; public Ring(){ Panel p=new Panel(new GridLayout(1, 1)); p.add(new Label("Ring")); p.add(tf3); tf3.addActionListener(this); add(p); } public void actionPerformed(ActionEvent e){ repaint(); } public void paint(Graphics ekraan){ String kask=tf3.getText(); ekraan.drawOval(keskx, kesky, x, y); if(kask.equals("vasakule") && keskx>x+5){ keskx=keskx-5;} if(kask.equals("paremale") && keskx<350-(2*x)){ keskx=keskx+5;} if(kask.equals("üles") && kesky>x+10){ kesky=kesky-5;} if(kask.equals("alla") && kesky<200-(2*x)){ kesky=kesky+5;} if(kask.equals("suuremaks") && x<60){ y=y+5; x=x+5;} if(kask.equals("väiksemaks") && x>5){ x=x-5; y=y-5;} } public static void main(String[] argumendid){ Frame f=new Frame("Aken"); f.setSize(350, 200); f.add(new Ring()); f.setVisible(true); f.addWindowListener(new aken_kinni()); } } class aken_kinni extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.out.println("Programm kinni"); System.exit(0); } }