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

📄 testactionevent2.java

📁 我的一个JAVA作业
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestActionEvent2 {
    public static void main(String args[]) {
	    JFrame f = new JFrame("Test");
       JButton b1 = new JButton("Start");
       JButton b2 = new JButton("Stop");
   	
   Monitor bh = new Monitor();
   b1.addActionListener(bh);       b2.addActionListener(bh);	       b2.setActionCommand("game over");
   f.getContentPane().add(b1,"North");       f.getContentPane().add(b2,"Center");	
   f.pack();        	f.setVisible(true);    }}
class Monitor implements ActionListener {
 public void actionPerformed(ActionEvent e) {
 System.out.println("a button has been pressed, the relative info is: " + e.getActionCommand());    
}
}

⌨️ 快捷键说明

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