𝓱𝓲𝓶 𝓫𝓾𝓽 𝓯𝓻𝓮𝓪𝓴𝔂
𝓱𝓲𝓶 𝓫𝓾𝓽 𝓯𝓻𝓮𝓪𝓴𝔂
JCHJava Community | Help. Code. Learn.
Created by 𝓱𝓲𝓶 𝓫𝓾𝓽 𝓯𝓻𝓮𝓪𝓴𝔂 on 11/23/2024 in #java-help
Program Randomly Quitting After Font.createFont() statement
After I try to get the font "ggsans", which is in the src/main/resources folder, the program randomly quits with exit code 1. Code
static {
try {
System.out.println("Test Statement!");
ggReg = Font.createFont(Font.TRUETYPE_FONT, new File("ggsans.ttf"));
ggBold = Font.createFont(Font.TRUETYPE_FONT, new File("ggsansbold.ttf"));
} catch (FontFormatException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public static void main(String[] args) {
System.out.println("Test Statement!");
frame = new JFrame();
System.out.println("Test Statement!");
frame.add(new MainPanel());
System.out.println("Test Statement!");
frame.setVisible(true);
System.out.println("Test Statement!");
}
static {
try {
System.out.println("Test Statement!");
ggReg = Font.createFont(Font.TRUETYPE_FONT, new File("ggsans.ttf"));
ggBold = Font.createFont(Font.TRUETYPE_FONT, new File("ggsansbold.ttf"));
} catch (FontFormatException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public static void main(String[] args) {
System.out.println("Test Statement!");
frame = new JFrame();
System.out.println("Test Statement!");
frame.add(new MainPanel());
System.out.println("Test Statement!");
frame.setVisible(true);
System.out.println("Test Statement!");
}
6 replies