my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Popup menu not responding with mouse event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Popup menu not responding with mouse event" Watch "Popup menu not responding with mouse event" New topic
Author

Popup menu not responding with mouse event

priya gnana
Greenhorn

Joined: Jun 08, 2008
Posts: 14
i have added popupmenu to the applet...based on the menu selected methods 'll be
called..now the problem is,for all menu selection only a particular method is called..can anyone
say me where i'm going wrong..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

Some pointers:
You should be adding the mouse listener to the panel, not to the popup and menu items.
If you are using JDK1.5+ take a look at JComponent#setComponentPopupMenu()
You should check for isPopupTrigger on mousePressed AND mouseReleased(Check out the API documentation) Please note a mouseClick=mousePress+mouseRelease.
I dont see any code which checks which menu/item was selected
You subclass AbstractAction and add it directly to the popup to eliminate the if/else looks for checking which menu/item was selected


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
priya gnana
Greenhorn

Joined: Jun 08, 2008
Posts: 14

if(MonthlyView.contains(p))
{
monthly_view =true;
repaint();
}
else if(fitAll.contains(p))
{
fit_all = true;
repaint();
}


i have mention the menu selection in mouse pressed method.
 
jQuery in Action, 2nd edition
 
subject: Popup menu not responding with mouse event
 
Similar Threads
Messagebox with Mouseevent
Dispalying random dates
Drop Down Menu Buttons
My scrollbars are not displaying
looking for a graphical representation