Article View: borland.public.jbuilder.java.swing
Article #10316Re: key accelerator for JMenu
From: Wendy Lin
Date: Thu, 14 Oct 1999 00:00
Date: Thu, 14 Oct 1999 00:00
61 lines
2137 bytes
2137 bytes
Short Cut Key is only for AWT menu items.
In Swing's JMenuItem you'll need to write a little bit of code for
accelerators.
Example:
JMenutItem aboutMenuItem = new JMenuItem("About");
aboutMenuItem.setAccelerator(KeyStroke.getKeyStroke('A',
java.awt.Event.SHIFT_MASK, false));
This sets the accelerator to shift-A.
Another way to do a short cut is to use menomic property:
JMenutItem aboutMenuItem = new JMenuItem("About");
aboutMenuItem.setMnemonic('A');
This underlines A, I guess it is also refer to as Hot Key.
Hope this helps.
--Wendy
JBuilder QA
nick bhanji <nbhanji@home.com> wrote in message
news:7u5ekq$4he4@forums.borland.com...
> Hi,
>
> I am trying to use Key accelarator for menu items. When I select
> Accelarator in the menuitem properties
> it comes up <none>. I looked up in the help file which comes up as
follows:
>
> "
> Specifying keyboard shortcuts
>
> Keyboard shortcuts enable the user to perform a menu action by typing in a
> shortcut key combination. For example, a
> commonly used shortcut for File|Save is Ctrl+S.
>
> To specify a keyboard shortcut for a menu item,
>
> Select the menu item in the menu designer or in the component tree.
> In the Inspector, select the shortcut property and enter a value or choose
a
> key combination from the drop-down list.
> This list is only a subset of the valid combinations you can use.
>
> When you add a shortcut, it appears next to the menu item at runtime.
> "
>
> Can some one please check to make sure I am not the only one having the
> problem.
>
> Thanks in Advance
> nick.b
>
>
>
Technical Details
Message-ID:
<7u5les$4hi17@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7u5ekq$4he4@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,df80e8f377c66df7 X-Google-Attributes: gid111d45,public From: " Wendy Lin" <wlin@borland.com> Subject: Re: key accelerator for JMenu Date: 1999/10/14 Message-ID: <7u5les$4hi17@forums.borland.com> X-Deja-AN: 536846373 References: <7u5ekq$4he4@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Organization: Borland X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing