Article View: borland.public.jbuilder.java.swing
Article #8058Re: JTextFieldSize
From: Joi Ellis [TeamB]
Date: Tue, 21 Nov 2000 00:00
Date: Tue, 21 Nov 2000 00:00
28 lines
1780 bytes
1780 bytes
James A. Schulz <jaschulz@wiseware.com> wrote: > I want a JTextField that will accomodate exactly 50 Monospaced characters. > I set the "Columns" property to 50, but that doesn't seem to have any effect > because I can enter more than 50 characters and the dimensions of the field > give it much more width than it needs. The size of the field controls only its physical image on the screen. It does not limit the amount of text which can be entered into the document underneath. > I know that fonts are variable from platform to platform, but this app > requires a precise size for this field. Is my only strategy to determine > the font character width at run time and then resize my entire applet? Yes, if you must specify a size. I avoid specifying sizes as much as possible and rely upon layout managers to handle it. > Please tell me there is an easier way. When I want to do this, I set the text to 50 'M' characters, pack, and then ask the component for its preferred size. That's the size I use. Generally I do this when I want an input field to be blank at startup but sized appropriately for typical inputs. -- Joi Ellis (TeamB) No direct email, please. For best results, post on news server newsgroups.borland.com!
Technical Details
Message-ID:
<8vengv$qj311@bornews.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8vemot$qj46@bornews.inprise.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,69aa350fde3e11dc
X-Google-Attributes: gid111d45,public
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: JTextFieldSize
Date: 2000/11/21
Message-ID: <8vengv$qj311@bornews.inprise.com>
X-Deja-AN: 696308281
References: <8vemot$qj46@bornews.inprise.com>
Organization: Another Netscape Collabra Server User
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.14-5.0 (i686))
Newsgroups: borland.public.jbuilder.java.swing