🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14688

Re: How to know the string width in pixels

#14688
From: nlaan
Date: Fri, 13 Aug 1999 00:00
14 lines
829 bytes
Sorry, my mistake the correct method is used as followed:

public void paint(Graphics g)
{
    FontMetrics fm = g.getFontMetrics();

    int width = fm.stringWidth("Hello World");

    int height = fm.getHeight();
}

>> FontMetrics fm = new FontMetrics(Font f);
>
>The class FontMetrics is an abstract class; cannot be instantiated.
Technical Details
Message-ID: <7p1i94$i4v18@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37B447DD.A8A3FB9F@ucbcba.edu.bo>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,65a7d2b5fc13dd18
X-Google-Attributes: gidf74b3,public
From: <nlaan>
Subject: Re: How to know the string width in pixels
Date: 1999/08/13
Message-ID: <7p1i94$i4v18@forums.borland.com>
X-Deja-AN: 512317456
References: <37B447DD.A8A3FB9F@ucbcba.edu.bo>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.language