|
|
Re: A JButton with Double Listener
|
Posted: Apr 18, 2005 8:12 AM
|
|
How to make them work both Simultaneously You don't need to do anything to do that. Adding more than one listener automatically enables all listeners. Depending on what you do another one is called. If 2 listeners need to do the same thing, then justcall the same method.
The mnemonic solution is probably what you need. If you need the button being activated with different keys, you need of course a listener for the key typed (or pressed) event, then call the same method as the action listener does or create a action performed event and fire it.
The action performed event can be activated in 3 ways: clicking on the button, using the mnemonic, typing "space" or "enter" while the button has the focus.
If you need instead a solution like "mouse klicked while holding Crtl button", you need to look at the MouseEvent and mask the event's value.
|
|