import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.awt.image.*; public class Lambike extends Applet implements ActionListener{ Image lamp=Toolkit.getDefaultToolkit().getImage("lamp.gif"); Button nupp=new Button(" Lamp põlema "); Button nupp1=new Button(" Tuttu ja lamp kustu! "); public Lambike(){ add(nupp); add(nupp1); nupp.addActionListener(this); nupp1.addActionListener(this); } public void actionPerformed(ActionEvent e){ Graphics g=this.getGraphics(); if(e.getSource()==nupp){ g.setColor(Color.yellow); g.fillOval(40,290,200,200); } if(e.getSource()==nupp1){ g.setColor(Color.white); g.fillOval(40,290,200,200); } } public void paint(Graphics g){ g.drawImage(lamp, 0, 0, getWidth(), getHeight(), this); } public static void main(String argumendid[]){ Frame f=new Frame("Õpime lampi ökonoomselt kasutama"); f.setSize(840, 970); f.add(new Lambike()); f.setVisible(true); } }