import java.awt.*; import java.awt.event.*; import java.applet.*; public class Teljed3 extends Applet implements ActionListener{ double a=3; TextField tf1=new TextField(String.valueOf(a)); double b=5; TextField tf2=new TextField(String.valueOf(b)); double vanay; public Teljed3(){ 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); int algx=-100; vanay=a*algx+b; for(int x=algx; x<100; x++){ double y=a*x+b; if(y*vanay<=0){ g.drawOval((int)x+100-5, 200-5, 10, 10); } g.drawOval(x+100, 200-(int)y, 1, 1); vanay=y; } // 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 Teljed3()); f.setSize(250, 250); f.setVisible(true); } }