So I've been playing around with JButtons and I've been trying to add an ImageIcon to a JButton. I have the following code:
window = new JFrame("Test");
window.setSize(1000, 600);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(null);
Icon icon = new ImageIcon("/Apple.jpg");
JButton apple = new JButton(icon);
apple.setBounds(50, 50, 200, 200);
window.add(apple);
I was wondering where would the Apple.jpg file have to be located for the code to work? Currently, Apple.jpg is located in the same package as this class.