Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Popup Menu

Status
Not open for further replies.

blairacuda

Technical User
Sep 3, 2009
51
US
Hello Java Gurus,

I am new to Java and am playing around with popup menus. For some reason my menu item is throwing a compiler error.

Here is my Code:

1. JPopupMenu pm = new JPopupMenu();;
2. MenuItem mi = new MenuItem("Add");
3. mi.addActionListener(this);
4. mi.setActionCommand("add");
5. pm.add(mi); <-- This line is giving me an error

Error:
Cannot find symbol
symbol: method add(java.awt.MenuItem)
location: class javax.swing.JPopupMenu

I feel like it is something simple but can't figure it out...

Thanks in advance,
Chris



Chris Blair
Crystal, InstallShield, branching out in other programming realms.
 
Never mind...

I figured it out as soon as I posted this... I just declared mi as JMenuItem instead of MenuItem.

-Chris

Chris Blair
Crystal, InstallShield, branching out in other programming realms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top