Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Keyboard focus getting lost

1 view
Skip to first unread message

Kenneth P. Turvey

unread,
Aug 16, 2008, 4:15:31 AM8/16/08
to
I have an applet that loads a component that uses any number of other
components internally. When it is first running the component gets the
KeyPressed events that I want it to, but then after doing anything with
the mouse, it no longer gets these events. I think that the focus must
be on one of the sub-components, but I don't know which one. I've tried
setting everything to not be focusable, but I must be missing something.

Isn't there some way that the top level component can always see key
events for it or any sub component? That's all I really need. I just
want all events to go to my top level component.

Thanks.

--
Kenneth P. Turvey <kt-u...@squeakydolphin.com>
http://www.electricsenator.net

Duct tape is like the force. It has a light side, and a dark side,
and it holds the universe together ...
-- Carl Zwanzig

Kenneth P. Turvey

unread,
Aug 16, 2008, 4:16:31 AM8/16/08
to
On Sat, 16 Aug 2008 08:15:31 +0000, Kenneth P. Turvey wrote:

> I have an applet that loads a component that uses any number of other
> components internally. When it is first running the component gets the
> KeyPressed events that I want it to, but then after doing anything with
> the mouse, it no longer gets these events. I think that the focus must
> be on one of the sub-components, but I don't know which one. I've tried
> setting everything to not be focusable, but I must be missing something.
>
> Isn't there some way that the top level component can always see key
> events for it or any sub component? That's all I really need. I just
> want all events to go to my top level component.
>
> Thanks.

Another possibility is a way to set mnemonics to answer to Ctrl-whatever
instead of alt-whatever.

Thanks.

The only two things that are infinite in size are the universe and
human
stupidity. And I'm not completely sure about the universe.
-- Albert Einstein

John B. Matthews

unread,
Aug 16, 2008, 10:46:03 PM8/16/08
to
In article <48a68ca2$0$2196$ec3e...@news.usenetmonster.com>,

"Kenneth P. Turvey" <kt-u...@squeakydolphin.com> wrote:

> I have an applet that loads a component that uses any number of other
> components internally. When it is first running the component gets the
> KeyPressed events that I want it to, but then after doing anything with
> the mouse, it no longer gets these events. I think that the focus must
> be on one of the sub-components, but I don't know which one. I've tried
> setting everything to not be focusable, but I must be missing something.

[...]

Might this be relevant: "In general, pressing the Tab key moves focus
through the major components; Shift-Tab moves through the components in
the reverse direction. Control-Tab and Control-Shift-Tab work in a
similar fashion and are necessary when keyboard focus is in an element
that accepts tabs, such as a text area."

<http://java.sun.com/products/jlf/ed2/book/HIG.Behavior3.html>

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

Kenneth P. Turvey

unread,
Aug 17, 2008, 5:55:17 PM8/17/08
to
On Sat, 16 Aug 2008 22:46:03 -0400, John B. Matthews wrote:

> Might this be relevant: "In general, pressing the Tab key moves focus
> through the major components; Shift-Tab moves through the components in
> the reverse direction. Control-Tab and Control-Shift-Tab work in a
> similar fashion and are necessary when keyboard focus is in an element
> that accepts tabs, such as a text area."
>
> <http://java.sun.com/products/jlf/ed2/book/HIG.Behavior3.html>

This wasn't the problem. My initial attempts to get this to work were
correct, but I missed a key step. Basically I called setFocusable(false)
on each of the components in my applet. This included a toolbar. What I
didn't do is to call setFocusable(false) on each of the buttons in the
toolbar. Once I did this, the app worked as expected.

Thanks for your suggestion.

The only two things that are infinite in size are the universe and

Daniele Futtorovic

unread,
Aug 17, 2008, 6:09:29 PM8/17/08
to
On 17/08/2008 23:55, Kenneth P. Turvey allegedly wrote:
> My initial attempts to get this to work were
> correct, but I missed a key step. Basically I called setFocusable(false)
> on each of the components in my applet. This included a toolbar. What I
> didn't do is to call setFocusable(false) on each of the buttons in the
> toolbar. Once I did this, the app worked as expected.

You can do that recursively, you know...

--
DF.

Kenneth P. Turvey

unread,
Aug 17, 2008, 7:34:31 PM8/17/08
to

Good point. That would probably be the way to go. I'm not getting paid
anymore for this project, but in the future that's probably how I'll do
it.

Thanks.

I took the initiative in creating the Internet.
-- Al Gore

0 new messages