⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testactionlistenerr.java

📁 Java讲义与实例
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class testActionListenerr extends JFrame{
	private JPanel jpanel1;
	private JButton jb1=new JButton("按钮");
	public testActionListenerr(){
		super("testActionListener");
		setSize(300,100);
		jpanel1=new JPanel();
		jpanel1.add(jb1);
		jb1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				log("按钮被操作....");
				log("命令字符串:"+e.getActionCommand());
				log("事件发生时间:"+e.getWhen());
				}
			});
		this.setContentPane(jpanel1);
		}
    public void log(String strInfo){
    	System.out.println(strInfo);
    	}
    public static void main(String agg[]){
    	testActionListenerr ta1=new testActionListenerr();
    	ta1.show();
    	}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -