If I call action by myself then what should I send to actionPerformed(ActionEvent e) as e? My logic does not use this parameter so I can send null, but what is sent here regularly? If action is called by button, then what it sends here?
If I call action by myself then what should I send to actionPerformed(ActionEvent e)
Share
In general, you pass 3 or 4 parts (according to the constructors for
ActionEvent):Component, but can really be anything; generally the originating piece of the UI that resulted in the event being generated),ActionEvent.ACTION_PERFORMED, but could also beActionEvent.ACTION_FIRSTorActionEvent.ACTION_LAST),AbstractButton.getActionCommand),ActionEvent.ALT_MASK | ActionEvent.SHIFT_MASKif the user held AltShift while performing the action).The modifiers are optional, everything else is required. You can also pass a
whenfor the timing of the event, but generally isn’t necessary as it defaults to when the event was constructed.