🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Swing JTextField: Focus-Lost-Problem

#10973
From: meiser
Date: Fri, 23 Jul 1999 00:00
37 lines
1711 bytes
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: <37985A4D.CE55F327@metafinanz.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mv4v6$esf10@forums.borland.com> <3797B102.3CE24CD8@guest.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d9e76987c762ed78
X-Google-Attributes: gid111d45,public
From: meiser@metafinanz.de
Subject: Re: Swing JTextField: Focus-Lost-Problem
Date: 1999/07/23
Message-ID: <37985A4D.CE55F327@metafinanz.de>
X-Deja-AN: 504374730
Content-Transfer-Encoding: 7bit
References: <7mv4v6$esf10@forums.borland.com> <3797B102.3CE24CD8@guest.com>
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