e644. 处理Action事件

Action events are fired by subclasses of AbstractButton and includes buttons, checkboxes, and menus.

    AbstractButton button = new JButton("OK");
    button.addActionListener(new MyActionListener());
    
    public class MyActionListener implements ActionListener {
        public void actionPerformed(ActionEvent evt) {
            // Determine which abstract button fired the event.
            AbstractButton button = (AbstractButton)evt.getSource();
        }
    }

 

Related Examples
posted @ 2018-09-02 21:14  borter  阅读(234)  评论(0编辑  收藏  举报