Я не могу на всю жизнь понять, почему изображение ничего не возвращает. Я запускаю расположение в Windows Run, и оно открывается просто отлично.
public static void createAndShowGUI() {
System.out.println("Created GUI on EDT? "+
SwingUtilities.isEventDispatchThread());
JFrame f = new JFrame("Swing Paint Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(900,900);
f.setVisible(true);
ImageIcon dudey = createImageIcon("C:\\Users\\madsa\\Desktop\\JavaStuff\\TestTiles\\Enemy.png");
JButton one = new JButton("Click the PP", dudey);
one.setVerticalTextPosition(AbstractButton.CENTER);
one.setHorizontalTextPosition(AbstractButton.LEADING);
}
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL= painting.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}