Button:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="ButtonDemo" width=300 height=100></applet>*/
public class ButtonDemo extends Applet implements ActionListener
{
Label l1;
public void init()
{
Button b1 =new Button("Yes");
b1.addActionListener(this);
add(b1);
Button b2=new Button("No");
b2.addActionListener(this);
add(b2);
Button b3=new Button("Cancel");
b3.addActionListener(this);
add(b3);
l1=new Label(" ");
add(l1);
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("Yes"))
{
l1.setText(str);
}
else if(str.equals("No"))
{
l1.setText(str);
}
else
{
l1.setText(str);
}
}
}
Comments
Post a Comment