• 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

JButton with a pop up menu

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JButton that I want to add a menu to, I was using a mouseClicked and listening for 1 or 2 clicks, 2 bringing up the menu. The problem is that this button fires a single click to quickly and it is hard to get a double click in. So I create an arrow icon to memic a drop down button, on mousePressed the menu pops up just as it should, however if the user just wanted to use the button ( a single click ) they are not able to do so because the mouse pressed fires and ignores the release. How can I determine if the user has simple pressed the button or are they holding the button to get the menu?
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On press button start a timer with reasonable delay. In the timer action check pressed state. If the button still pressed show your popup. On release action stop the timer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic