🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Setting Focus Won't Work

#12352
From: Paul Waldo
Date: Wed, 13 Jan 1999 00:00
31 lines
1435 bytes
Hi all,

I'm having a very frustrating problem with focus.  I have created a
JDialog that has a number of focusable components.  I want to explicitly
set the focus to a JTextField that does not get the initial focus.  I am
using the following code:

  JTextField userId = new JTextField(8);

in jbinit ()...
    System.out.println (userId.isFocusTraversable ());
    System.out.println (userId.isRequestFocusEnabled ());
    System.out.println
(com.sun.java.swing.FocusManager.isFocusManagerEnabled ());
    System.out.println (getRootPane ().isManagingFocus ());
    userId.requestDefaultFocus ();
    userId.requestFocus ();
    System.out.println (userId.hasFocus ());

The focus never changes to the userId component and the output looks
like this:
true
true
true
false
false

It seems like everything goes OK, but the focus never gets changed.  I'm
stumped.  Anyone have any ideas?  TIA

Paul Waldo
Technical Details
Message-ID: <369CC78B.CABDD184@bna.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,223cd5ce51a082af,start
X-Google-Attributes: gid111d45,public
From: Paul Waldo <pwaldo@bna.com>
Subject: Setting Focus Won't Work
Date: 1999/01/13
Message-ID: <369CC78B.CABDD184@bna.com>
X-Deja-AN: 432167799
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing