1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| private static Font police = null;
// ceci est ton cache qui contient les polices chargées
// bon ici y'en a qu'une seule mais c'est pareil
private static void initFont() {
//méthode qui charge la police dans le cache
InputStream ttf;
try {
ttf = new FileInputStream("/font/e.ttf");
police = Font.createFont(Font.TRUETYPE_FONT, ttf);
}
catch (Exception e) {
police = new Font("gulim", Font.PLAIN, 60);
}
}
public static void changePoliceCaractere(JLabel lbl) {
if(police == null)
initFont();
lbl.setFont(police.deriveFont(70f));
} |
Partager