🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17524

Re: Adding 'global' keyboard events

#17524
From: John P. McGrath
Date: Wed, 28 Oct 1998 00:00
29 lines
1668 bytes
Scott Ottesen <sottesen@dced.state.ut.us> wrote:

> I'm trying to find a way to put a "global" KeyEvent listener
> together for all the forms that share the same data module.
> So far, all I see is to create KeyEvent listener's in all
> separate form classes instead of one single class.  I've
> already put together a class that will work the data between
> all the forms if I make separate KeyEvent calls to it from
> each form, but all those separate calls seems like a lot
> of overhead for one form.  Is there such a way to bind all
> forms to default to one separate KeyEvent listener class?

Yes.  You can have a single KeyListener listen to the KeyEvents 
from any number of Components.  But you will have to register the 
listener with each Component using addKeyListener().

The AWT does not handle this sort of thing very well, whereas 
Swing provides much better support, allowing you to do just what 
you want with only a single method call per keystroke.  It also 
provides better support for managing the focus.  If you are not 
already using Swing, you should consider it for your next 
project.

-- 
Regards,

John P. McGrath
<mcgrath@enter.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.10a0a89f7f773b209896e8@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <362B5A27.D837433A@dced.state.ut.us>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,339ee7bcb7a9db48
X-Google-Attributes: gidf74b3,public
From: mcgrath@enter.net (John P. McGrath)
Subject: Re: Adding 'global' keyboard events
Date: 1998/10/28
Message-ID: <MPG.10a0a89f7f773b209896e8@forums.inprise.com>
X-Deja-AN: 405869528
References: <362B5A27.D837433A@dced.state.ut.us>
Organization: Software Consulting Services
Newsgroups: borland.public.jbuilder.java.language