I am going to convert my project into jar file. I am setting all my images and other external files with this.getClass().getResource("");
I have no problem with adding images;
xButton.setIcon(new ImageIcon(this.class.getResource("/a/b/c/d/e.png")));
But I can't register font with this method;
...
private final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
...
try {
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File(this.getClass().getResource("fonts/f1.ttf"))));
// or either
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File(MYCLASS.class.getResource("/a/b/c/d/f1.ttf"))));
// or either
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File(this.class.getResource("/a/b/c/d/f1.ttf"))));
} catch (FontFormatException e2) {
e2.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
Error I am getting from Eclipse is : The constructor File(URL) is undefined.