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
7 Replies
โ
This post has been reserved for your question.
Hey @๐ฑ๐ฒ๐ถ ๐ซ๐พ๐ฝ ๐ฏ๐ป๐ฎ๐ช๐ด๐! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
It outputs just one "Test Statement" and then exits
One thing to note is that there's a lil pause in between the first test statement and the quit.
Output
๐ค
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
new File("ggsans.ttf")
File
operates with file system. For loading from classpath (which is what src/main/resources belongs to) you have to use something else, eg , https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html#getResourceAsStream(java.lang.String)
frame = new JFrame();you shouldn't be interacting with swing component classes outside of swing thread. Use https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/SwingUtilities.html#invokeLater(java.lang.Runnable)
SwingUtilities (Java SE 17 & JDK 17)
declaration: module: java.desktop, package: javax.swing, class: SwingUtilities
Class (Java SE 17 & JDK 17)
declaration: module: java.base, package: java.lang, class: Class
this worked, thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@663052037688131614>.