jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes No mnemonic displayed in tooltip? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "No mnemonic displayed in tooltip?" Watch "No mnemonic displayed in tooltip?" New topic
Author

No mnemonic displayed in tooltip?

Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hello all!

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?

Thanks!

Darrin


Life is good on the Ponderosa,<br />but mind where you step.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38436
    
  23
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.
Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hi Campbell,

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!

Thanks,

Darrin
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38436
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No mnemonic displayed in tooltip?