Reputation: 30097
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?
Upvotes: 0
Views: 61
Reputation: 17299
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 be ActionEvent.ACTION_FIRST
or ActionEvent.ACTION_LAST
),AbstractButton.getActionCommand
),ActionEvent.ALT_MASK | ActionEvent.SHIFT_MASK
if the user held AltShift while performing the action).The modifiers are optional, everything else is required. You can also pass a when
for the timing of the event, but generally isn't necessary as it defaults to when the event was constructed.
Upvotes: 2
Reputation: 21902
Read the doc for ActionEvent. The constructors documentation will tell you what you want to know. For more information, you could also simply add a button and a breakpoint. Press the button and get all the details.
Upvotes: 2