🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2637

Getting the size of type.....

#2637
From: Dave Bird
Date: Sat, 26 Aug 2000 00:00
20 lines
1389 bytes

Is it possible to get the typesetting height, and the average character
width, of the font currently in use [like this old :-( microsoft code]?

protected Dimension getCharDimension(Container parent){     //to get
    FontMetrics m = parent.getFontMetrics(parent.getFont());//char size
    String s  =  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int  width  = m.stringWidth(s) / s.length();  if(width<=0)width = 1;  
    int  height = m.getHeight();     return new Dimension(width,height);
} 


There appears to be no nonabstract FontMetrics, and no getFontMetrics(), 
in the current Swing java.  I am confused.................
                                                  

-- 
   ^-^-^-@@-^-;-^   http://www.xemu.demon.co.uk/
        (..)__u     news:alt.smoking.mooses
Technical Details
Message-ID: <PjkhtkAZnEq5Ewul@xemu.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,df69827445be6a91,start
X-Google-Attributes: gid1089d0,public
From: Dave Bird <dave@xemu.demon.co.uk>
Subject: Getting the size of type.....
Date: 2000/08/26
Message-ID: <PjkhtkAZnEq5Ewul@xemu.demon.co.uk>
X-Deja-AN: 662859415
X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209
X-Trace: news.demon.co.uk 967330508 nnrp-02:29201 NO-IDENT xemu.demon.co.uk:158.152.196.209
Organization: very little
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
X-Complaints-To: abuse@demon.net