import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class joonistapastakas3 extends Applet implements ActionListener{ TextField tfKorgus=new TextField("250",5); int pastakas_yleval=0; Button pikenda=new Button("Näita otsa/ära näita otsa"); public joonistapastakas3(){ add(tfKorgus); add(pikenda); pikenda.addActionListener(this); } public void paint(Graphics g){ int pastakaKorgus=Integer.parseInt(tfKorgus.getText()); g.setColor(new Color(200, 100, 100)); g.setColor(Color.black); g.drawLine(25, 100, 25, pastakaKorgus); g.drawLine(45, 100, 45, pastakaKorgus); g.drawLine(25, pastakaKorgus, 45, pastakaKorgus); g.drawLine(25, 100, 30, 80); g.drawLine(45, 100, 40, 80); g.drawLine(30, 80, 40, 80); if (pastakas_yleval==0){ pastakas_yleval = 1; g.setColor(Color.white); g.drawLine(35, 80, 35, 70); } else{ pastakas_yleval = 0; g.setColor(Color.black); g.drawLine(35, 80, 35, 70); } } public void actionPerformed(ActionEvent e){ repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("joonistapastakas3"); f.setSize(200, 500); f.add(new joonistapastakas3()); f.setVisible(true); } }