I'd like to use the TrueTypeFont class from sun.font.TrueTypeFont package in my applet, but Eclipse keeps complaining about the constructor not being visible:
import sun.font.TrueTypeFont;
.
.
.
new TrueTypeFont("a", new Object(), 1, false);
yields:
- The constructor TrueTypeFont(String, Object, int, boolean) is not visible
Is there a way to fix this? Is 开发者_如何学JAVAthere a way to cast Font
class to TrueTypeFont
? I need to get data provided by methods of TrueTypeFont.
You have multiple problems there:
sun.font.TrueTypeFont
is an implementation class that you shouldn't be playing around with.- It's constructor is "package private" (default access) which means you can't access it from another package (which is what Eclipse happens to be telling you).
- Even if you could access it, an [untrusted] applet cannot access
sun.*
classes (controlled by thepackage.access
security property).
精彩评论