Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Keyboard focus getting lost

瀏覽次數:1 次
跳到第一則未讀訊息

Kenneth P. Turvey

未讀,
2008年8月16日 凌晨4:15:312008/8/16
收件者:
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

未讀,
2008年8月16日 凌晨4:16:312008/8/16
收件者:
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

未讀,
2008年8月16日 晚上10:46:032008/8/16
收件者:
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

未讀,
2008年8月17日 下午5:55:172008/8/17
收件者:
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

未讀,
2008年8月17日 下午6:09:292008/8/17
收件者:
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

未讀,
2008年8月17日 晚上7:34:312008/8/17
收件者:

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 則新訊息