🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
4 messages
4 total messages Started by Bruce Houghtron Tue, 12 Jun 2007 16:04
requestFocus and JTextField
#259
Author: Bruce Houghtron
Date: Tue, 12 Jun 2007 16:04
16 lines
1641 bytes
To all;
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..
Bruce Houghton
Re: requestFocus and JTextField
#260
Author: 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
Re: requestFocus and JTextField
#261
Author: Bruce Houghtron
Date: Tue, 12 Jun 2007 21:07
40 lines
2577 bytes
Damit your good. Thanks allot, I've been fighting this
problem for a long time. Now I can also fix my Login
screen. The customer always asked why I couldn't put
the cursor in the Password Field on the Login screen
Thanks again...
Bruce Houghton

"Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote in message 
news:xn0f7d6r7cpko2001-kdean@www.teamb.com...
> 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 
Re: requestFocus and JTextField
#262
Author: Paul Furbacher [TeamB]
Date: Tue, 12 Jun 2007 21:27
48 lines
2705 bytes
Kevin Dean [TeamB] wrote:
> 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.

The old way of doing this was to override addNotify().  One has to be
careful to call super.addNotify(), otherwise there's trouble.

     public void addNotify() {
       super.addNotify();
       myTextField.requestFocus();
     }


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads