USE OF SHOW AND CLEAR BUTTON IN BUTTON CLASS
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet
code="ButtonDemo2" height=200 width=200>
</applet>
*/
public class ButtonDemo2 extends Applet implements
ActionListener
{
Button
b1,b2;
Label
msg;
public
void init()
{
msg=new
Label("
");
add(msg);
b1=new
Button("Show");
add(b1);
b1.addActionListener(this);
b2=new
Button("Clear");
add(b2);
b2.addActionListener(this);
}
public
void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
msg.setText("Welcome
To AWT");
else
if(ae.getSource()==b2)
msg.setText("");
}
Comments
Post a Comment