When I run the jar file it turns into a default font, unlike when I run it in netbeans the code works perfectly fine.
This is my code:
public class login extends javax.swing.JFrame {
/**
* Creates new form login
*/
Font bitWon;
Font deMono;
Font deSans;
Font dotumChe;
public login() {
initComponents();
try {
bitWon = Font.createFont(Font.TRUETYPE_FONT, new File("src/8-BIT WONDER.TTF")).deriveFont(36f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("src/8-BIT WONDER.TTF")));
jLabel2.setFont(bitWon);
deMono = Font.createFont(Font.TRUETYPE_FONT, new File("src/determinationmonoweb-webfont.ttf")).deriveFont(24f);
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("src/determinationmonoweb-webfont.ttf")));
jLabel3.setFont(deMono);
jLabel4.setFont(new Font(deMono.getName(), Font.PLAIN, 18));
jButton1.setFont(new Font(deMono.getName(), Font.PLAIN, 24));
deSans = Font.createFont(Font.TRUETYPE_FONT, new File("src/determinationsansweb-webfont.ttf")).deriveFont(14f);
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("src/determinationsansweb-webfont.ttf")));
jPasswordField1.setFont(deSans);
jTextField1.setFont(deSans);
dotumChe = Font.createFont(Font.TRUETYPE_FONT, new File("src/dotumche-pixel.ttf")).deriveFont(10f);
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("src/dotumche-pixel.ttf")));
jLabel7.setFont(dotumChe);
}
catch(IOException | FontFormatException e){
}
The fonts (ttf) is placed in the default package, with my main class.
I tried using the inputstream but it only made it not work in netbeans and the jar file too.