import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JFrameTest extends JFrame{
private JButton button;
private Container content;
private int count=0;
public JFrameTest(){
super("JFrameTest");
this.setBounds(100,100,300,200);
content=this.getContentPane();
content.setLayout(new FlowLayout());
button=new JButton("还没有点击哦");
content.add(button);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
count++;
button.setText("点击了"+count+"次");
}
});
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
new JFrameTest();
}
}