Does & actually create a mnemonic?

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Does & actually create a mnemonic?

Postby darryl » Wed Jun 01, 2005 4:42 am

Hi,

I'm adding a '&' character to menu text to get a Mnemonic, but nothings happening. The & character is simply displayed with the other text. If I manually add a setMnemonic() in the source then nothing happens in the designer or preview, but the underline works as expected when I run the application.

Has something broken in the latest 4.0.1 update (29 May 2005) or did it never work? Am I missing something?

Regards


Darryl
darryl
 
Posts: 1
Joined: Wed Jun 01, 2005 4:18 am

Re: Does & actually create a mnemonic?

Postby Eric Clayberg » Wed Jun 01, 2005 5:17 am

darryl wrote:I'm adding a '&' character to menu text to get a Mnemonic, but nothings happening. The & character is simply displayed with the other text. If I manually add a setMnemonic() in the source then nothing happens in the designer or preview, but the underline works as expected when I run the application.

Swing menu items and buttons don't use ampersands to indicate mnemonics (SWT does do this).

In Swing you need to use setMnemonic() and optionally displayedMnemonicIndex().

Designer supports both of those properties. For mnemonics, we use the setMnemonic(int) form. For example:

Code: Select all
menuItem.setMnemonic(KeyEvent.VK_J);
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest