//内部
监听器
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JFrameDemo5 extends JFrame{
public JFrameDemo5() {
setTitle("学生管理系统");
setSize(200, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
final JButton jb=new JButton("天下第一");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jb.setText("世界第二");
jb.setSize(100, 100);
jb.setBackground(Color.blue);
}
});
jb.setBounds(0, 0, 90, 20);
add(jb);
setVisible(true);
}
public static void main(String[] args) {
new JFrameDemo5();
}
}
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JFrameDemo5 extends JFrame{
public JFrameDemo5() {
setTitle("学生管理系统");
setSize(200, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
final JButton jb=new JButton("天下第一");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jb.setText("世界第二");
jb.setSize(100, 100);
jb.setBackground(Color.blue);
}
});
jb.setBounds(0, 0, 90, 20);
add(jb);
setVisible(true);
}
public static void main(String[] args) {
new JFrameDemo5();
}
}