I'm trying to get icons to appear on my command buttons, but no matter where I put them on the HDD, they don't seem to appear. I though placing them in the same directories as the source must work but even nothing then. My code is as follows:
Can anyone see what I'm doing wrong?
Thanks
Code:
import javax.swing.*;
public class IconFrame extends JFrame
{
JButton load, save, subscribe, unsubscribe;
public IconFrame()
{
super("Icon Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
// Create Icons
ImageIcon loadIcon = new ImageIcon("load.gif");
ImageIcon saveIcon = new ImageIcon("save.gif");
ImageIcon subscribeIcon = new ImageIcon("subscribe.gif");
ImageIcon unsubscribeIcon = new ImageIcon("unsubscribe.gif");
// Create Buttons
load = new JButton("Load", loadIcon);
save = new JButton("Save", saveIcon);
subscribe = new JButton("Subscribe", subscribeIcon);
unsubscribe = new JButton("Unsubscribe", unsubscribeIcon);
// Add Button to Panel
panel.add(load);
panel.add(save);
panel.add(subscribe);
panel.add(unsubscribe);
// Add the panel to the frame
add(panel);
pack();
setVisible(true);
}
public static void main(String[] arguments)
{
IconFrame ike = new IconFrame();
}
}
Can anyone see what I'm doing wrong?
Thanks