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

相关文章:

  • 2022-02-25
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
猜你喜欢
  • 2021-12-26
  • 2021-11-08
相关资源
相似解决方案