/* */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class bgcolor extends Applet implements ActionListener { TextField t1,t2,t3; Button b; int i=0,j=0,k=0; Button b1,b2,b3,b4; public void init() { setBackground(Color.white); t1=new TextField(3); t2=new TextField(3); t3=new TextField(3); t1.addActionListener(this); t2.addActionListener(this); t3.addActionListener(this); b=new Button("Enter"); b.addActionListener(this); b1=new Button("RED"); b2=new Button("GREEN"); b3=new Button("BLUE"); b4=new Button("YELLOW"); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); add(t1); add(t2); add(t3); add(b); add(b1); add(b2); add(b3); add(b4); } public void actionPerformed(ActionEvent e1) { String s=e1.getActionCommand(); if(s.equals("Enter")) { try { i=Integer.parseInt(t1.getText()); j=Integer.parseInt(t2.getText()); k=Integer.parseInt(t3.getText()); } catch(NumberFormatException e) {System.out.println("NUmberFormat Error ::");} setBackground(new Color(i,j,k)); } else 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); } }