Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

shortcut defining problem in AWT

Thread view: 
AimsLife - 13 Sep 2007 08:04 GMT
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
Andrew Thompson - 13 Sep 2007 10:55 GMT
...
>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/api/java/awt/event/KeyEvent.html#KeyEvent(java
.awt.Component,%20int,%20long,%20int,%20int,%20char

)>

Signature

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

AimsLife - 13 Sep 2007 11:34 GMT
Hi,

> >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.

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
Roedy Green - 13 Sep 2007 11:02 GMT
>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));
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.