Search code examples
javaswingactionlistenerjmenu

Action when menu is opened


My friend is having trouble adding an action when a menu is opened. He won't ask for help from anyone so here I am.

The project is a tetris game. We need a system to run a pause method whenever a menu is opened and an unpause method when it is closed.

Any suggestions?


Solution

  • Assuming you are using Swing - Take a look at addMenuListener and addActionListener.