import java.awt.*; import java.applet.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Graafik1 extends Applet implements ActionListener{ TextField tf=new TextField(5); public Graafik1(){ add(tf); tf.addActionListener(this); } public void paint(Graphics g){ g.setColor(Color.black); g.drawLine(4000,220,0,220 ); g.drawLine(220,4000,220,0 ); int vanax=140; int vanay=60; for(int x=-80; x<=80; x++){ int uusx=x+220; int uusy=220-(x*x/40); g.drawLine(vanax, vanay, uusx, uusy); vanax=uusx; vanay=uusy; } } public void actionPerformed(ActionEvent e){ int nr=Integer.parseInt(tf.getText().trim()); Graphics g=getGraphics(); g.drawLine(nr+220, 220, nr+220, 220-nr*nr/40); g.drawLine(nr+220,220-nr*nr/40,220,220-nr*nr/40); } public static void main(String argumendid[]){ Frame f=new Frame("Ruutfunktsiooni graafik"); f.add(new Graafik1()); f.setSize(250, 250); f.setVisible(true); } }