javascript
Brief description  about Online courses   join in Online courses
View preethy  kp 's Profile

what are the errors

could you please tell me what are the errors in the following program.I can find any error.But teacher said me to redo the program


import java.awt.*;
import java.awt.event.*;

public class awt5
{
public static void main(String[] args)
{
Frame frame=new Frame("Applet Program5");

Panel p1=new Panel();

Button b;

ActionListener aa=new a();

p1.add(b=new Button("Name"));
b.setActionCommand("Name");
b.addActionListener(aa);

p1.add(b=new Button("Place"));
b.setActionCommand("Place");
b.addActionListener(aa);

p1.add(b=new Button("College"));
b.setActionCommand("College");
b.addActionListener(aa);

p1.add(b=new Button("Actor"));
b.setActionCommand("Actor");
b.addActionListener(aa);

p1.add(b=new Button("Programming Language"));
b.setActionCommand("Programming language");
b.addActionListener(aa);

frame.add(p1,BorderLayout.CENTER);

frame.setLayout(new FlowLayout());
frame.setSize(350,350);
frame.setVisible(true);

frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
}


class a implements ActionListener
{
public void itemStateChanged(ItemEvent ie)
{

}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();

if(s.equals("Name"))
{
System.out.println("Preethymol.k.p");
}
if(s.equals("Place"))
{
System.out.println("Ernakulam");
}
if(s.equals("College"))
{
System.out.println("FISAT");
}
if(s.equals("Actor"))
{
System.out.println("Amir Khan");
}
if(s.equals("Programming language"))
{
System.out.println("JAVA");
}

}
}
Asked by preethy kp | Nov 24, 2010 |  Reply now
Replies (1)
View arun kumar das 's Profile
HI

Its correct

java teacher
Dec 8, 2010