• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

close a frame with menu item

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

on a jframe i have a jmenu bar with a jmenu and 2 jmenuitem,
i try to close my application...



in my jMenuItem2MouseClicked.....
i click on the item.... but this event never happen....
any idea?

thanks
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mouseClicked() does not fire if the mouse is moved during mousePressed and mouseReleased()
try changing to mousePressed(), see if it works

any reason you're not using an actionListener for this?
 
mark smith
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
mouseClicked() does not fire if the mouse is moved during mousePressed and mouseReleased()
try changing to mousePressed(), see if it works

any reason you're not using an actionListener for this?



thanks work fine with mousePressed.....

don't know, i'm a newbies with java gui.... have you an example for that?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> have you an example for that?

this method name
jMenuItem2MouseClicked
is generated by netbeans(?), I don't know what the equivalent is for
actionListener - it's not important, just the argument 'type' needs changing
from MouseEvent to ActionEvent

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic