We recently upgraded from the 1.4.2 line of the JDK to the latest Java 6 version (repeat after me, "Generics are easy, the syntax is beautiful <repeat as needed> . One change I cannot figure out is the loss of the "accelerator" keys from the tooltips. Using 1.4.2, the tooltips would display as "This is your tooltip <Alt-K>", with "K" being your defined mnemonic for the button, etc. I am (unfortunately) using the Metal look and feel, so I checked the UIDefaults, and the listed value "ToolTip.hideAccelerator=false" seems like they should still show up? Does anyone know if this was changed on purpose, or how to get the mnemonic back into the tooltips?
Life is good on the Ponderosa,<br />but mind where you step.
Don't know. I tried a little class with a tool tip and compiled it with J1.4.2 and J6; on 1.4.2 I got "B for Button <alt-B>", and on J6 the B on the button was underlined.
Joined: Dec 27, 2002
I ran a test with multiple JDK versions and determined the change appeared between the 1.5 and 1.6 JDKs. Looking at the source code, it seems that the MetalToolTipUI.paint() method IS attempting to resolve the accelerator string and add it to the tooltip, but the getAcceleratorString() method returns an empty string. A little debugging revealed the problem to be the call to:
This returns no keys, so the method returns the empty string. The accelerator key works in the example above, so I'm not sure why no keys are returned. It would seem that the keystroke mapping from Alt-C to the button is working! The 1.5 version of the getAcceleratorString() method is vastly different, so it looks like something was lost in the translation. Oh well, another bug report!
Joined: Oct 13, 2005
Thank you. I haven't got J5 any more, only 1.4.2 and 6. My example has "0x62" (B) as its mnemonic; it works with alt-B.