File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Popup menu not responding with mouse event

 
priya gnana
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
priya gnana
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic