🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TextField size

#18335
From: Jennifer Merkel
Date: Thu, 09 Jul 1998 00:00
25 lines
1622 bytes
Laurent,

I have done what you are trying to do.  Here is my solution:  I used
setColumns(int) to set the columns to 1 greater than I wanted the field
to be.  Then I added a KeyListener to the field and implemented the
keyTyped(KeyEvent) method.  Whenever a key is typed it checks to see if
the current length of the textfield (getText().trim().length()) is equal
to the value of getColumns() - 1.  If it is equal then I consume the
event, e.consume().  I hope this helps.

Jennifer

Laurent LEFEVRE wrote:

> Is there a way to limit the number of char in a TextField ?
> The TextField.setColumns(int) method seems to not work
>
> --
> Laurent LEFEVRE
> ====================================================================
> CO2W3         Parc d'activit� P�gase,            Tel : 02.96.05.82.40
>               1 rue Fulgence Bienven�e           Fax : 02.96.05.82.41
>               22300 LANNION - FRANCE             http://www.co2w3.fr
> --------------------------------------------------------------------
>  Logiciels Cooperatifs - Services Internet - Materiel Informatique
Technical Details
Message-ID: <35A4C375.6E3A4DD0@EdmundsAssoc.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35A37E01.A93C38A0@co2w3.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,fb14619c6d82a7ca
X-Google-Attributes: gidf74b3,public
From: Jennifer Merkel <JenniferM@EdmundsAssoc.com>
Subject: Re: TextField size
Date: 1998/07/09
Message-ID: <35A4C375.6E3A4DD0@EdmundsAssoc.com>
X-Deja-AN: 369859300
Content-Transfer-Encoding: 8bit
References: <35A37E01.A93C38A0@co2w3.fr>
Content-Type: text/plain; charset=iso-8859-1
Organization: Edmunds & Associates
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language