📄 testactionevent.java
字号:
package test.gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestActionEvent {
public static void main(String[] args) {
JFrame frame = new JFrame();
JButton b = new JButton("test action event");
frame.add(b);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Component c = (Component) e.getSource();
c.setBackground(Color.blue);
}
});
frame.setSize(400,400);
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -