🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JTextField validation

#11533
From: Gavin
Date: Wed, 19 May 1999 00:00
21 lines
1761 bytes
Looks like I missed the boat on this one, but why not create a textfield where
an invalid value CANNOT be entered?  Just write your own textfield subclass and
ensure any invalid keystrokes are ignored.

Jason Burton wrote:

> > If you get a focus lost event, note that you *ALREADY* lost focus.  Focus
> > is *GONE*.  Another component *ALREADY* has the focus.  To move focus
> > back, the new component gets a focus lost event.  Will you then validate
> > the new component as well losing focus back to the original?
> > See how complicated all this is?  I personally highly advise *AGAINST*
> > doing things on a focus lost.  One good way to do validation is on each
> > keystroke by writing your own Document.  It's quite easy.
>
> A simple "user changed field" flag can be used to determine whether or not
> to perform validation.  This will prevent validation from occuring in the
> newly focused field when it is determined that the input in the last field
> is invalid.  Validating on key strokes can be a bad choice for things like
> database lookups based on current field value.
>
> Jason Burton
Technical Details
Message-ID: <374294F8.8313952B@apion-tss.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7fg4uv$suv26@forums.borland.com> <MPG.1185a5346cbef1cf9896d7@forums.borland.com> <7fi16l$1kh12@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,816558d5accb6dda
X-Google-Attributes: gid111d45,public
From: Gavin <g.cassidy@apion-tss.com>
Subject: Re: JTextField validation
Date: 1999/05/19
Message-ID: <374294F8.8313952B@apion-tss.com>
X-Deja-AN: 479574169
Content-Transfer-Encoding: 7bit
References: <7fg4uv$suv26@forums.borland.com> <MPG.1185a5346cbef1cf9896d7@forums.borland.com> <7fi16l$1kh12@forums.borland.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