Article View: borland.public.jbuilder.java.swing
Article #13163Re: Keyboard accelerators???
From: Tad Frysinger
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
28 lines
1563 bytes
1563 bytes
In article <35FE010B.7DF802C3@linuxcanada.com>, brad@linuxcanada.com
says...
> I'm trying to use keyboard accelerators for menus. You know
> something like Alt-F for the File menu and then "x" to exit.
> Whenever I use setAccelerator() on a menu though I get a ton
> of error messages when I use the application plus the frame
> doesn't show up. I would post the error messages from the
> stack trace but it scrolls way past so I'm missing the real
> important part (note: how do I fix this???). When I run the
> application through the debugger I don't even see the errors
> scroll by. Why is this?
>
I agree that setting accelerators with JMenu is not really intuitive.
Try this (assiming menuFileExit is a JMenuItem):
menuFileExit.setText("Exit");
menuFileExit.setAccelerator(
KeyStroke.getKeyStroke( 88,
java.awt.Event.CTRL_MASK));
menuFileExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuFileExit_actionPerformed(e);
}
});
Tad Frysinger
[TeamB]
Technical Details
Message-ID:
<MPG.10686d4ea62199749898e5@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35FE010B.7DF802C3@linuxcanada.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,858c838fa4c06d5f X-Google-Attributes: gid111d45,public From: tfrysinger@uswest.net (Tad Frysinger) Subject: Re: Keyboard accelerators??? Date: 1998/09/15 Message-ID: <MPG.10686d4ea62199749898e5@forums.borland.com> X-Deja-AN: 391443150 References: <35FE010B.7DF802C3@linuxcanada.com> Organization: FreeZone Enterprises Newsgroups: borland.public.jbuilder.java.swing