import java.applet.Applet.*; import java.awt.*; import java.awt.event.*; public class assign extends Applet implements ActionListener{ TextField txt1; Buttons cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7; public void init(){ txt1= new TextField(20); add(txt1); cmd1= new Button(); add(cmd1); cmd1.addActionListener(this); cmd1.setBackground(Color.blue); cmd2= new Button(); add(cmd2); cmd2.addActionListener(this); cmd2.setBackground(Color.green); cmd3= new Button(); add(cmd3); cmd3.addActionListener(this); cmd3.setBackground(Color.cyan); cmd4= new Button(); add(cmd4); cmd4.addActionListener(this); cmd4.setBackground(Color.pink); cmd5= new Button(); add(cmd5); cmd5.addActionListener(this); cmd5.setBackground(Color.black); cmd6= new Button(); add(cmd6); cmd6.addActionListener(this); cmd6.setBackground(Color.Brown); cmd7= new Button(); add(cmd7); cmd7.addActionListener(this); } public void actionPerformed (ActionEvent objEvent) { if (objEvent.getSource () == cmd1) txt1.setText ("BLUE"); if (objEvent.getSource () == cmd2) txt1.setText ("GREEN"); if (objEvent.getSource () == cmd3) txt1.setText ("PINK"); if (objEvent.getSource () == cmd4) txt1.setText ("CYAN"); if (objEvent.getSource () == cmd5) txt1.setText ("BLACK"); if (objEvent.getSource () == cmd6) txt1.setText ("BROWN"); if (objEvent.getSource () == cmd7) txt1.setText (" "); } }
can u please help me. .i hav 4 errors in that code.