wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Selecting A Menu Item Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Selecting A Menu Item" Watch "Selecting A Menu Item" New topic

Selecting A Menu Item

simon keillor

Joined: Jun 23, 2004
Posts: 24

Have created a frame with a nice menu on it and hav added a popup menu as well.

Now how do I get my app to respond to someone clicking on a menu item? Am armed with my 'Teach Yourself Java In 21 Days' bible but doesn't cover this.



Steve JK

Joined: Jun 16, 2004
Posts: 5
Hi Simon,

for each menu item you have, do the following:


where you substitute 'menuItem' for the actual name of your menu item, then

public void actionPerformed(ActionEvent e)
//..code to do whatever

That should work for you


Happy Coding all!
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link: http://aspose.com/file-tools
subject: Selecting A Menu Item
Similar Threads
simple web browser in java
Swing graphic problem
enable and disable a menu item in a menu bar
To set the F1 key as shortcut for menuitem Help
a JMenuItem question,the value is too long