Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Keyboard control of the java.awt
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Keyboard control of the java.awt



This isn't a Mac-specific java problem, but there may be a Mac-specific solution and anyway some of you may welcome a break from coding over the weekend to tell me that what I want to do is either simple or impossible.

What I want to do is to have keyboard control as an alternative to clicking on a custom button (i.e. canvas coord-specified area) or a awt Choice radio-button to implement the code that these would initiate. For example, I might want to use some of the F-keys as alternatives to choices or command-i as an alternative to clicking on an area to get info.

Now I already know how to use the modifier keys (option, command, control) working on a canvas, and I know how to add a KeyListener to a text area to get it to respond to 'enter'. What I cannot manage to do is add a KeyListener to a canvas or a panel with buttons set in a layout structure ultimately in a frame.

I tried a cut-down version of the 1.1 example in Flangan's 'Java Examples in a Nutshell', which works on an app with a graphic layout of just an awt Frame. (This involves enableEvents(AWTEvent.KEY_EVENT_MASK) and processKeyEvent(KeyEvent e)) and that worked fine, but failed as soon as I added a component to the Frame. There's no example of this in Geary either.

Easy? Possible? Hopeless? (or a book recommendation)

David
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.