📄 testactionevent.java
字号:
package test.gui;import java.awt.Color;import java.awt.Component;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;public class TestActionEvent { public static void main(String[] args) { // TODO Auto-generated method stub 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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -