import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Pasta2 extends Applet implements ActionListener{ Button a=new Button("tera");int x=0; public Pasta2(){ add(a); a.addActionListener(this); } public void paint(Graphics g){ g.fillRect(100, 100, 200, 20); g.setColor(Color.blue); g.drawLine(300, 120, 320, 110); g.drawLine(300, 100, 320, 110); if(x==1){g.drawLine(320, 110, 325, 110);} } public void actionPerformed(ActionEvent e){ if(x==1){x=0;}else{x=1;} repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Pasta2 joonistamine"); f.setSize(600, 300); f.add(new Pasta2()); f.setVisible(true); } }