aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 10266
    
    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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Popup menu not responding with mouse event