import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class sample01 extends Applet implements ActionListener{ boolean check_sw = false; public void init() { setBackground(Color.white); Button butt = (Button)add(new Button("Push Button")); butt.addActionListener(this); } public void actionPerformed(ActionEvent e) { if (check_sw) { this.check_sw = false; }else { this.check_sw = true; } repaint(); } public void paint(Graphics g) { Font font = new Font("MS–¾’©", Font.BOLD ,40); g.setFont(font); if (check_sw) { g.setColor(Color.red); g.drawString("ON", 10, 80); }else{ g.setColor(Color.blue); g.drawString("OFF",10, 80); } } }