Article View: borland.public.jbuilder.java.swing
Article #9563Re: Font question
From: Bill Joy
Date: Mon, 28 Feb 2000 00:00
Date: Mon, 28 Feb 2000 00:00
15 lines
1021 bytes
1021 bytes
If you are using JDK 1.2, you can use the Font.getStringBounds()
method. For example:
Font font = UIManager.getFont("TextField.font");
FontRenderContext frc = new FontRenderContext(null,false,false);
String str = "string";
int width = font.getStringBounds(str, frc).getWidth();
Timothy Reaves wrote:
>
> How can I get the size of a String during the jbinit method? At
> this time there is no Graphics object to get a FontMetrics object from.
>
> Any help appreciated.
Technical Details
Message-ID:
<38BB01E2.E6305215@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<38BADA98.64AFC2A0@silverfields.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,144e0e52f359d13c X-Google-Attributes: gid111d45,public From: Bill Joy <bjoy@inprise.com> Subject: Re: Font question Date: 2000/02/28 Message-ID: <38BB01E2.E6305215@inprise.com> X-Deja-AN: 591069973 Content-Transfer-Encoding: 7bit References: <38BADA98.64AFC2A0@silverfields.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Inprise Corporation Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing