JMenuItem to access and manipulate a variable

189 views Asked by At

I am implementing a game in java and I am setting up the difficulty settings. I have each difficulty setting in a JMenuItem on a menu bar. I was wondering how do I access and manipulate a variable in another class by using those menu items. Thanks any help is appreciated!

1

There are 1 answers

0
Stuck On

The other component should implement the ActionListener interface. Then add the instance of that other component as action listener:

yourMenutItem.addActionListener(otherComponent);