I’m developing a java application and I create a dynamic JMenu by hand (depending on the input data). I add the same action for each menu item of the menu. The problem is that depending on the menu item called I would like to take a different action each time. Is there a simple way of doing this (Something like setData(Object data) for each JMenuItem or am I forced to derive from JMenuItem)?
Thanks in advance,
Iulian
i guess you can use ActionEvent.getSource in the actionPerformed method of your Action. compare the source of the event with your JMenuItem’s.
to store additional info, you can use putClientProperty or extend JMenuItem