Domanda

Mi piacerebbe utilizzare la classe TrueTypeFont dal pacchetto Sun.Font.trueTypefont nella mia applet, ma Eclipse continua a lamentarti del costruttore che non è visibile:

import sun.font.TrueTypeFont;
.
.
.    
new TrueTypeFont("a", new Object(), 1, false);
.

rendimenti:

    - The constructor TrueTypeFont(String, Object, int, boolean) is not visible
.

C'è un modo per risolvere questo?C'è un modo per lanciare la classe Font a TrueTypeFont?Ho bisogno di ottenere dati forniti dai metodi di TrueTypeFont.

È stato utile?

Soluzione

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 the package.access security property).
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top