This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring 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:
subject: Selecting A Menu Item
It's not a secret anymore!