[3922] in java-interest

home help back first fref pref prev next nref lref last post

How Do I Access FontMetrics

daemon@ATHENA.MIT.EDU (David Strauss)
Sun Dec 3 14:34:21 1995

Date: Sun, 3 Dec 1995 12:33:01 -0500 (EST)
To: java-interest@java.sun.com
From: dstrauss@panix.com (David Strauss)

I tried the following:

	Font f = myChooser.getFont();
	FontMetrics fm = new FontMetrics(f);

and got --

C:\Development\Java\Applets\Converter\Converter.java:110: class 
java.awt.FontMetrics is an abstract class. It can't be instantiated.
	FontMetrics fm = new FontMetrics(f);

	            
Realizing that I probably needed to find a Win32 specific class that
inherits from FontMetrics, I found Win32FontMetrics and did the following:


	import sun.awt.win32.*;
	.
	.
	Font f = myChooser.getFont();
	Win32FontMetrics fm = new Win32FontMetrics(f);

Now I got --

C:\Development\Java\Applets\Converter\Converter.java:110: Can't access class 
sun.awt.win32.Win32FontMetrics. Only public classes and interfaces in other 
packages can be accessed.
	Win32FontMetrics fm = new Win32FontMetrics(f);


Looking at the source code for FontMetrics reveals that the constructor
is declared protected, which I assume is the source of my problem.

So how do I access font metrics?


-- 
------------------------------------------------
David Strauss
E-mail: dstrauss@.panix.com 
        dstrauss@lehman.com 
-------------------------------------------------

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post