The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Problems with events (listeners) in AWT ...

Posted by Radu Mirescu on November 10, 2000 at 11:50 AM

I need to create a small application in AWT (why AWT? since I must used jdk1.1.8 which cand be run safely under 16M restriction - a slow machine).
I have a "main" class which extends Frame.
I added a listener to this in order to process the keyboard events to emulate menu shortcuts.
I failed.
I failed also to process the keyboard events (using listeners) for checkboxes.
The only trick which works was to use a TextField instance in each page, with focus in it, in order to capture the Shortcuts KeyStrokes (for this particular application the use of shortcuts is vital).
Which is strange is I tried the Bruce Eckel example (from Thinking in Java) which captures all the events for an array of panels. It works! But there is apparent no difference between this example and my application (I used also addKeyLister and KeyReleased function to capture the KeyCode).
Could anybody help me? (to receive keyboard events for pannels using AWT?).
There is a trick concerning the events?
I saw some "strange" methods like Notify(), Dispatch().
I think that these methods for component are from the old version of interface which do NOT work with this oriented to listeners (as is written in Thinking in Java).
I saw also a class AWTMulticast or something like that.
What is intendend for?
I finish here. Please help me if you could.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us