import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Lamp2 extends Applet implements MouseListener{ int varv=0; public Lamp2(){ addMouseListener(this); } public void paint(Graphics g){ g.setColor(Color.black); g.fillRect(90, 70, 30, 70); g.setColor(Color.yellow); g.fillOval(80, 10, 50, 70); } public void mousePressed(MouseEvent e){} public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){ Graphics g=getGraphics(); Graphics g1=getGraphics(); try{ if(varv==0){ g.setColor(Color.yellow); g.fillOval(80, 10, 50, 70); varv=1; } else if(varv==1){ g1.setColor(Color.white); g1.fillOval(80, 10, 50, 70); varv=0; } }catch(Exception viga){} } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String argumendid[]){ Frame f=new Frame(); f.add(new Lamp2()); f.setSize(300, 300); f.setVisible(true); f.setBackground(Color.blue); } }