import java.awt.*;
import java.awt.event.*;
public class E5_2{
public static void main(String args[]){
Myframe m=new Myframe();
m.setVisible(true);

}
class Myframe extends Frame{
Mypanel mp=new Mypanel();
Myframe(){
setSize(300,300);
add(mp);
}

}
class Mypanel extends Panel implements ActionListener{
public String s;
public int c;
public Mypanel(){
    Button b=new Button("按钮");
Label l=new Label("标签");
add(b);
add(l);
setLayout(new FlowLayout());
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b){
c++;
s=new String("您单击了"+c+"次");
l.setText("哈哈");
}
}
}