shortcut defining problem in AWT

A

AimsLife

Hi,

I am using jdk1.5 Kit for application development. I am using AWT for
gui interface making. Can you please guide me, how I can define
shortcut of menu like Alt+F?

I tried below statement for define shortcut of menu but it works on
Ctrl key.

fileMenuItemOpen.setShortcut(new MenuShortcut(KeyEvent.VK_F));

Please guide me, how we can control menu using Alt key? Is it possible
in AWT?

Regards,
-aimslife
 
A

Andrew Thompson

AimsLife wrote:
...
I am using jdk1.5 Kit for application development. I am using AWT for
gui interface making.

Why are you coding AWT GUI's to run in Java 1.5?
Swing would be the far more common option in
this millennium.
..Can you please guide me, how I can define
shortcut of menu like Alt+F?

Did you try RTFM, or are you simply coding by
typing random statemenets into the IDE?
I tried below statement for define shortcut of menu but it works on
Ctrl key.

Yes. As the FM describes.
Please guide me, how we can control menu using Alt key? Is it possible
in AWT?

Sure. Try reading the FM. Start with that clue to
'KeyEvent' in the constructor for the 'MenuShortcut'.
<http://java.sun.com/javase/6/docs/a...java.awt.Component, int, long, int, int, char
)>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
R

Roedy Green

fileMenuItemOpen.setShortcut(new MenuShortcut(KeyEvent.VK_F));

menuItem = new JMenuItem("A text-only menu item",
KeyEvent.VK_T);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_1, ActionEvent.ALT_MASK));
 
A

AimsLife

Hi,
Why are you coding AWT GUI's to run in Java 1.5?
Swing would be the far more common option in
this millennium.

I am using some third party controls and they are using AWT, thats
why, I am developing gui in one type of components.

I need to define short key on Menu not Menu Item. Please tell me, the
way to define acceleration on menu.

Regards,
-aimslife
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,797
Messages
2,569,647
Members
45,377
Latest member
Zebacus

Latest Threads

Top