Gui- JMenu help

I created a JMenu with JMenuItems with options like a regular menu on Microsoft word. I know the JMenuItem class has a method called "isSelected()". However, where should I call this method in my class in order for this option to work. For example, the "open" JMenuItem should display a GUI to find what file to open. I tried to put this method in the actionPerformed method but it didn't work during runtime. Is there another interface I need to implement?

[465 byte] By [imgnakikurbta] at [2007-11-27 4:28:48]
# 1

You don't. You add an ActionListener to the "open" menu item and that ActionListener's actionPerformed method will be called when someone clicks on it. Then you'll know it's selected and can do whatever.

Or you create an Action class, which is similar, except it also can define other things for the menu item.

http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

bsampieria at 2007-7-12 9:37:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Oh! Thank you! I forgot about that.
imgnakikurbta at 2007-7-12 9:37:39 > top of Java-index,Java Essentials,Java Programming...