import java.awt.*;
import java.awt.event.*;
class ButtonExample extends WindowAdapter implements ActionLiatener{
Frame f;
Button b;
TextField tf;
int tag=0;
public static void main(String args[]){
ButtonExample be=new ButtonExample();
be.go();
}
public void go(){
f=new Frame("Button Example");
b=new Button("Sample");
b.addActionListener(this);
b.add(tf,"Center");
f.addWindowListener(this);
f.setSize(300,500);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
String s1="You have pressed the Button!";
String s2="You do another time!";
if(tag==0){
tf.setText(s1);
tag=1;
}else{
tf.setText(s2);
tag=0;
}
}
public void actionPerformed(WindowEvent e){
System.ext(0);
}
}