import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Diagramm2 extends Applet implements ActionListener{ int pikkus1=150; int alaserv=300; TextField tf1=new TextField(String.valueOf(pikkus1)); public Diagramm2(){ add(tf1); tf1.addActionListener(this); } public void paint(Graphics g){ alaserv=getHeight()-20; double koef=(getHeight()-50)/200.0; g.drawLine(50, alaserv, 50, (int)(alaserv-pikkus1*koef)); } public void actionPerformed(ActionEvent e){ pikkus1=Integer.parseInt(tf1.getText()); repaint(); } public static void main(String[] arg){ Frame f=new Frame("tulbad"); f.setSize(400, 400); f.add(new Diagramm2()); f.setVisible(true); } }