import java.awt.*; import java.awt.event.*; import java.applet.*; public class Teljed2 extends Applet implements ActionListener{ double a=3; TextField tf1=new TextField(String.valueOf(a)); double b=5; TextField tf2=new TextField(String.valueOf(b)); public Teljed2(){ add(tf1); add(tf2); tf1.addActionListener(this); tf2.addActionListener(this); } public void paint(Graphics g){ g.drawLine(100, 0, 100, getHeight()); g.drawLine( 0, 200, getWidth(), 200); for(int x=-100; x<100; x++){ g.drawOval(x+100, 200-(int)(a*x+b), 1, 1); } double nullkoht=-b/a; g.drawOval((int)nullkoht+100-5, 200-5, 10, 10); } public void actionPerformed(ActionEvent e){ a=Double.parseDouble(tf1.getText()); b=Double.parseDouble(tf2.getText()); repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Ruutfunktsiooni graafik"); f.add(new Teljed2()); f.setSize(250, 250); f.setVisible(true); } }