🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14757

Re: JTextField size

#14757
From: Marcel van den Dungen
Date: Fri, 06 Aug 1999 00:00
30 lines
1471 bytes
perhaps the following dirty trick will do:
just add a keylistener to the textfield
and keep track of the entry, keep the length of the string, take into
regard backspaces and
deletes and so.  the just use the setText method to change the text to the
first ten characters every time the user types in his 11th character

possibly things will look better if the textfield's paint method is
overriden so actually only the first ten characters are drawn. instead of
the 11th character that is deleted everytime

i have no idea how it looks but it moght work fine..

greetings
casper

David wrote:

> Good day -
>
> Using JBuilder 3 -
>
> I have several JTextFields that the user types into.  I would like to
> restrict the number of characters to 10 (for example).  Has anyone done
> this?  I thought perhaps DocumentListener was the solution, but couldn't
> get it to work.
>
> I would greatly appreciate any help you can offer.
>
> David
Technical Details
Message-ID: <37AAC8F6.B945E756@c-content.nl>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37A9FA85.279DCA47@lmco.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4e0efe8fe5a13afc
X-Google-Attributes: gidf74b3,public
From: Marcel van den Dungen <info@c-content.nl>
Subject: Re: JTextField size
Date: 1999/08/06
Message-ID: <37AAC8F6.B945E756@c-content.nl>
X-Deja-AN: 509553187
Content-Transfer-Encoding: 7bit
References: <37A9FA85.279DCA47@lmco.com>
Organization: C-CONTENT b.v.
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language