🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to know the size in pixels???

#10811
From: nlaan
Date: Thu, 12 Aug 1999 00:00
31 lines
1333 bytes
Use the java.awt.FontMetrics class.  And next time post your request to
borland.public.jbuilder.java.language

ie:

FontMetrics fm = new FontMetrics(Font f);

int width = fm.getWidth(String str);
int height = fm.getHeight();

----------------------------------------------------------------------------
nathan laan                341 Avadh Bhatia Physics Building
University of Alberta   Edmonton, Alberta, Canada
nlaan@ualberta.ca


David V�squez Estrada wrote in message <37B18BC5.FDC58523@ucbcba.edu.bo>...
>Hi,
>
>I�m trying to know the size in pixels of a string that will be the text
>of a JLabel.
>At this time I can know the number of characters and the current font
>size, but the result of:   (number of characters * current Font size) is
>bigger than the required.
>
>Any suggestions?
>
>Thanks in advance
>
>David
>
Technical Details
Message-ID: <7ovhp2$g7u11@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37B18BC5.FDC58523@ucbcba.edu.bo>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,db95dab94e8fcb9e
X-Google-Attributes: gid111d45,public
From: <nlaan>
Subject: Re: How to know the size in pixels???
Date: 1999/08/12
Message-ID: <7ovhp2$g7u11@forums.borland.com>
X-Deja-AN: 512028873
References: <37B18BC5.FDC58523@ucbcba.edu.bo>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.swing