/* */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class colorbutton extends Applet implements ActionListener { Button b1,b2,b3; int i=0,j=0,k=0; public void init() { b1=new Button("RED"); b2=new Button("BLUE"); b3=new Button("GREEN"); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); add(b1); add(b2); add(b3); } public void actionPerformed(ActionEvent e1) { String s=e1.getActionCommand(); if(s.equals("RED")) setBackground(Color.red); else if(s.equals("GREEN")) setBackground(Color.green); else if(s.equals("BLUE")) setBackground(Color.blue); else if(s.equals("YELLOW")) setBackground(Color.yellow); } }