Article View: borland.public.jbuilder.java.swing
Article #11285Re: Problems with requestFocus() and requestDefaultFocus()
From: Matt Krevs
Date: Wed, 16 Jun 1999 00:00
Date: Wed, 16 Jun 1999 00:00
38 lines
1978 bytes
1978 bytes
Unfortunately, I have found setting initial focus to be far from simple. The
following code should work
SwingUtilities.invokeLater
(
new Runnable()
{
public void run()
{
// Set focus to the component
theComponent.requestFocus();
}
}
);
Thanks to Tal Lyron for the above code
Alexander Stanev <a_stanev@iname.com> wrote in message
news:7k4us1$jms6@forums.borland.com...
> Hi everyone.
> I work with JBuilder2.01 and JDK1.2.1. Recenly in my application, I've
> tried to set a focus on a particular JButton in my JForm when the form is
> creating. But the focus always go to the first added JButoon. Neither
> requestDefaultFocus(), nor requestFocus() is working. Default focus is
> painted (border around button ) when setDefaultButton() is called, but the
> actual focus remains on first added component. I've tried with
> FocusManager - focusNextComponent(), setting the next focusable item to be
> my desired Button, but I've failed again. Maybe I do something wrong? I
> don't want to use programmable click on item to get the focus - this is
not
> a clear decision, but in my case this is a only way to get the focus.
> Is this a Swing bug or it's a problem of JBuilder ? Pleace if You know how
> to set a focus on a particular item - tell me.
>
> Thank You in advance.
>
>
>
Technical Details
Message-ID:
<7k6l3o$l2i10@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7k4us1$jms6@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,a26bf9823a51282e X-Google-Attributes: gid111d45,public From: "Matt Krevs" <mattkrevs@flex.com.au> Subject: Re: Problems with requestFocus() and requestDefaultFocus() Date: 1999/06/16 Message-ID: <7k6l3o$l2i10@forums.borland.com> X-Deja-AN: 490033085 References: <7k4us1$jms6@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Reply-To: "Matt Krevs" <mattkrevs@flex.com.au> Newsgroups: borland.public.jbuilder.java.swing