• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Popup menu not responding with mouse event

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic