JSpinner and addKeyListener (again)

Hello

I have already read in the forum (and in other places) that in order to get the key event, it is enough to grab the Model, apply getTextField() and then get the JFormattedTextField.

The problem that is that, this worksonly if the focus is on the JTextField.

If the focus is on the up/down arrows, I can't get the key event.

What I am trying to do is this: if the user presses a button (e.g. the ALT button) to make the spinner go faster, when the user clicks on the arrow buttons.

I have tried to grab the jey event in various positions, but with no luck.

Any ideas / help?

[632 byte] By [teratakia] at [2007-11-27 4:56:01]
# 1
When you need to add a MouseListener to the buttons. Then in the mousePressed() event you need to check if the Alt key is down.
camickra at 2007-7-12 10:11:06 > top of Java-index,Desktop,Core GUI APIs...
# 2
The problem is that I can't find any method to get the JButton handler for these buttons.Am I missing something?
teratakia at 2007-7-12 10:11:06 > top of Java-index,Desktop,Core GUI APIs...
# 3
There is no direct API method to get at the buttons unless you start playing with the UI, but JSpinner is a container for the text field and the two buttons, so as a hack you should be able to use the Container.getComponent(...) method to get the button and add the listener to it.
camickra at 2007-7-12 10:11:06 > top of Java-index,Desktop,Core GUI APIs...
# 4
This method worked, with a bit of magic of course...
teratakia at 2007-7-12 10:11:06 > top of Java-index,Desktop,Core GUI APIs...