Java Swingæ¬èº«æä¾äºç°æçæé®æ§ä»¶JButton
å建ä¸ä¸ªæ°çæé®:JButton about = new JButtonï¼
è¿ä¸ªæé®è¯¥æ¾å°èååºï¼toolBar.add(about);
è¦ä¸ºæé®æ·»å äºä»¶ååºï¼éè¦ä½¿ç¨about.addActionListener(this)æ¥åè¯ç¨åºçå¬æé®æä¸æ¶çäºä»¶ï¼ActionListeneræ¯ä¸ä¸ªç¨åºæ¥å£ã
public class KyodaiUI extends JFrame implements ActionListener {...}å®ç°ActionListeneræ¥å£æ¯ä¸ºäºåè¯ç¨åºæè¦è¿è¡äºä»¶å¤çäºã
æåæ们å¾æ·»å ååºäºä»¶ç代ç :
public void actionPerformed(ActionEvent e) {
if (e.getSource() == about) {
温馨提示:答案为网友推荐,仅供参考