Article View: borland.public.jbuilder.java.swing
Article #10718Re: How to know the size in pixels???
From: David Vásquez Estrada
Date: Fri, 13 Aug 1999 00:00
Date: Fri, 13 Aug 1999 00:00
46 lines
1779 bytes
1779 bytes
Hi, > Use the java.awt.FontMetrics class. And next time post your request to > borland.public.jbuilder.java.language Thank for the recomendation but the borland.public.jbuilder.java.language is too slow to download from my place. > > > ie: > > FontMetrics fm = new FontMetrics(Font f); The class FontMetrics is an abstract class; cannot be instantiated. There is method in the SwingUtilities class: SwingUtilities.computeStringWidth(FontMetrics, String); But again, it needs a FontMetrics instance. The only way is to extend this class. Then we must implement some required methods like the getWidth()...then we get the same problem. Am I wrong, or is there anoth 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:
<37B43577.DF127B44@ucbcba.edu.bo>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37B18BC5.FDC58523@ucbcba.edu.bo> <7ovhp2$g7u11@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,db95dab94e8fcb9e X-Google-Attributes: gid111d45,public From: David Vásquez Estrada <vasquezd@ucbcba.edu.bo> Subject: Re: How to know the size in pixels??? Date: 1999/08/13 Message-ID: <37B43577.DF127B44@ucbcba.edu.bo> X-Deja-AN: 512280206 Content-Transfer-Encoding: 8bit References: <37B18BC5.FDC58523@ucbcba.edu.bo> <7ovhp2$g7u11@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing