🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Swing JTextField: Focus-Lost-Problem

#11001
From: Robert Schossleitner
Date: Mon, 26 Jul 1999 00:00
55 lines
2041 bytes
Hi Matthias,

only for information: I found two ways to solve this:

1. on Focus lost I start a thread which grabbs the focus again.

2. by using the input-masks of the db-swing Components.


/Robert


meiser@metafinanz.de schrieb in Nachricht
<37985A4D.CE55F327@metafinanz.de>...
>Hi,
>
>this solution does not work !! The problem is that the next component
receive
>the focus before the focus is set back to the first component, so the
>focusGained-method of the second component is executing. The solution with
an
>runtime-exception seemsd to be the only way to avoid loosing the focus.
>
>greetings
>
>Matthias
>
>CV wrote:
>
>> See http://www.codeguru.com/java/articles/445.shtml
>>
>> -CV
>>
>> Robert Schossleitner wrote:
>>
>> > Hi,
>> >
>> > in my application I have a JTextField in which a timevalue can be
entered.
>> > This timestring hat to be checked on leaving the field (by pressing the
>> > TAB or Enter-Key). If the format can not be converted, the focus
>> > should not be handed over to the next contol.
>> >
>> > The only way i found to prevent the focus to be changed is throwing a
>> > runtime-exception in the focusLost-Event-Procedure (a consume of the
>> > Focus-Event is not alowed.
>> > The Exception causes the hiding of the caret but the focus stays in the
>> > first field.
>> >
>> > Does anybody know a better way to solve this problem?
>> >
>> > greetings
>> >
>> > Robert
>
Technical Details
Message-ID: <7nh553$2167@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mv4v6$esf10@forums.borland.com> <3797B102.3CE24CD8@guest.com> <37985A4D.CE55F327@metafinanz.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d9e76987c762ed78
X-Google-Attributes: gid111d45,public
From: "Robert Schossleitner" <srro@ams.stiwa.com>
Subject: Re: Swing JTextField: Focus-Lost-Problem
Date: 1999/07/26
Message-ID: <7nh553$2167@forums.borland.com>
X-Deja-AN: 505304250
References: <7mv4v6$esf10@forums.borland.com> <3797B102.3CE24CD8@guest.com> <37985A4D.CE55F327@metafinanz.de>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.swing