So i wrote a game under jdk 7 which imported and drew graphics like that:
ImageReader.java:
public static BufferedImage button_quit;
public void fetchGraphics() {
try {
button_quit = ImageIO.read(new File("rsc/client/gui/button_quit.jpeg"));
} catch(Exception e) {
e.printStackTrace();
System.out.println("Exception thrown in ClientVariables.class while importing overlay graphics.");
}
}
DrawClient.java:
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(ClientVariables.button_quit, ClientVariables.quitButtonX, ClientVariables.quitButtonY, null);
repaint();
}
The problem - in jdk 7 it worked just fine, but since i upgraded to jdk 14 not a single graphic is imported, it only draws all the lines and stuff that is hardcoded. How do i have to change the code to make it work again, i have no clue (tutorials on how to draw images in java are from years ago therefore also in jdk 7 or 8)
Edit: Its the same code, the same ide not even another folder where stuff is located in. The positions of the graphics are as they should be. What i didn't mention before: The graphics are not loaded. i repeatedly get the stack trace and my error message. Stack Trace:
javax.imageio.IIOException: Can't read input file!
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1308)
at GUI.ClientVariables.(ClientVariables.java:100)
at MAIN.CodeEntry.main(CodeEntry.java:70)
What i suspect to maybe be the problem is that the code in the newer version doesn't expect the "rsc/" folder to be in the same folder as the "src/" folder but maybe somewhere else.
Well i solved it myself, might be some fuckup by the IDE. Basically, in the old program, the rsc/ folder was located in the same folder as the src/ folder which contains the packages of this application. Now the program searched for the rsc/ folder one folder above. Why? No clue. But it's solved.