🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #260

Re: requestFocus and JTextField

#260
From: Kevin Dean [TeamB]
Date: Tue, 12 Jun 2007 16:51
31 lines
2139 bytes
Bruce Houghtron wrote:

>I'll be dammed if I can get Focus on a JTextField at Load Time.
>I've tried everything(it seems). requestFocus, requestFocusInWindow,
>requestFocus(true)....
>I have two JDialog's, one with a JList, and one without. The one without
>works fine. One of the symptoms is that when I key something in, just 
>after load time, I
>get an "valueChanged" from the ListSelectionListener.
>
>I put a "requestFocus()" then a getFocusOwner() after the init is 
>complete. The
>getFocusOwner() shows "null".
>Like I say, it seems as if I have tried everything and  read everything I 
>can get
>my hands on... So far no luck..

The problem is that requesting focus is a window event and the window 
object hasn't been created yet.  Initializing a dialog or a frame creates 
only the Java objects, not the window handle.

Try hooking into the "componentShown" event on the window and requesting 
focus at that point.

-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <xn0f7d6r7cpko2001-kdean@www.teamb.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <466ec402$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,cd79719f41c7c23a
X-Google-Attributes: gid111d45,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com>
Subject: Re: requestFocus and JTextField
Newsgroups: borland.public.jbuilder.java.swing
References:  <466ec402$2@newsgroups.borland.com>
Organization: Dolphin Data Development Ltd.
User-Agent: XanaNews/1.18.1.6
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobrp]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Message-ID: <xn0f7d6r7cpko2001-kdean@www.teamb.com>
X-Ref: newsgroups.borland.com ~XNS:00000862
MIME-Version: 1.0
Content-Type: text/plain; format=flowed
NNTP-Posting-Host: 199.243.78.163
Date: 12 Jun 2007 09:51:36 -0700
X-Trace: newsgroups.borland.com 1181667096 199.243.78.163 (12 Jun 2007 09:51:36 -0700)
Lines: 31
X-Authenticated-User: kdean
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail