Article View: borland.public.jbuilder.java.api
Article #2439Re: Newbie Question
From: John McGrath TeamB
Date: Thu, 30 Nov 2000 00:00
Date: Thu, 30 Nov 2000 00:00
28 lines
1641 bytes
1641 bytes
On Wed, 29 Nov 2000 15:18:52 -0600, James A. Schulz wrote:
> I have a little Swing applet comprising a few buttons and a
> text field. I want the focus to start on the text field and
> stay there (i.e. it will never go to the buttons- which are
> operated by accelerator keys), but I don't see how to do that.
> I have tried myTextField.requestDefaultFocus() and
> myTextField.requestFocus (in both init() and jbInit() ), but
> neither does the job.
The requestFocus() method will have no effect before the component has
been realized (i.e. shown in a window). I am not certain how things
work with an applet, but for a frame or a dialog, you could override
the addNotify() method and request the focus there.
To keep the buttons from getting focus, you will have to arrange for
the component to return false for both isRequestFocusEnabled() and
isFocusTraversable(). The former can be done with the corresponding
setter method, but you will need to override the latter.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.148fe7caf2bdaf7c989d78@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<903rnn$4q41@bornews.inprise.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,2d0d8c90dee35058 X-Google-Attributes: gid1089d0,public From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Subject: Re: Newbie Question Date: 2000/11/30 Message-ID: <MPG.148fe7caf2bdaf7c989d78@forums.borland.com> X-Deja-AN: 699487883 References: <903rnn$4q41@bornews.inprise.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.api