| Author |
JButton with a pop up menu
|
Derrick Albers
Greenhorn
Joined: Nov 01, 2010
Posts: 20
|
|
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?
|
 |
Stanislav Lapitsky
Ranch Hand
Joined: Dec 01, 2009
Posts: 53
|
|
|
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.
|
 |
 |
|
|
subject: JButton with a pop up menu
|
|
|