package main; import java.awt.event.ActionListener; import javax.swing.JButton; public class Big7Button extends JButton { private int buttonID; private Form form; Big7Button (String label,int buttonID, Form form) { super(label); this.buttonID = buttonID; this.form = form; addActionListener(form); } Big7Button (String label, Form form) { super(label); this.form = form; addActionListener(label); } /* 功能按键监听安装 */ public void addActionListener(String label) { Big7ButtonFunctionListener myListener = new Big7ButtonFunctionListener(label,form); addActionListener(myListener); } /* 矩阵按键监听安装 */ public void addActionListener(Form form) { Big7ButtonActionListener myListener = new Big7ButtonActionListener(buttonID,form); addActionListener(myListener); } }