🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Editmask for jtextfield

#12338
From: John vanderWerf
Date: Sat, 23 Jan 1999 00:00
32 lines
1854 bytes
I am trying to start one and am on the way,  but running into some
problems.  The JTextField use the MVC (Model View Controller)
architecture,  the Model ( PlainDocument ) contains the data and  the
view (FieldView) displays it.

Sub-classing PlainDocument to allow only specific types of data you can
control what goes into the field.  Override the Document.insertString()
method to test whether to allow the insertion and/or modify the data
before adding it.

To attach your Document Class to the JTextField,  override
createDefaultModel() to return an instance of your Document sub-class.

That's the easy part.  The harder part comes when you try to remove data
from the document.  I think the approach I may take is to allow any
insertion or removal and  set a flag to indicate whether or not the data
passes all the edits.  If it does not,  then I would display it it in an
error colour.  If it does,  then I would display in standard colour.

My problem now is to figure out how to attach a sub-class of field view
to the JTextField subclass.  Does anyone know how to do that?

John v.


Bernd Schloemer wrote:

> Hallo,
>
> Does anywhone have an idea how to make an editmask for an Jtextfield
>
> regards Bernd
Technical Details
Message-ID: <36AA2ABE.36F76EB3@nbnet.nb.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36A840E9.B1DB4360@t-online.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,aa7d4a077db5238a
X-Google-Attributes: gid111d45,public
From: John vanderWerf <mvanderw@nbnet.nb.ca>
Subject: Re: Editmask for jtextfield
Date: 1999/01/23
Message-ID: <36AA2ABE.36F76EB3@nbnet.nb.ca>
X-Deja-AN: 436085929
Content-Transfer-Encoding: 7bit
References: <36A840E9.B1DB4360@t-online.de>
To: Bernd Schloemer <bSchloemer@t-online.de>
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