I am having difficulties with placing images on Buttons using Java Swing. I have placed all images in a package named icon. The frame is loading as well as the buttons. I cant seem to get the images on the buttons.
Can anyone point out my mistake please.
public Launch(){
getContentPane().setLayout(new BorderLayout());
desIcon = getImageIcon("Editor.gif");
selIcon = getImageIcon("icon/small_hand.gif");
delIcon = getImageIcon("icon/remove_icon.gif");
roadIcon = getImageIcon("road.gif");
rotateIcon = getImageIcon("rotate.gif");
juncIcon = getImageIcon("junction.gif");
buttonGroup = new ButtonGroup();
gridBag = new GridBagLayout();
setControls();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
private ImageIcon getImageIcon(String iconName) {
return new ImageIcon(iconName);
//return new ImageIcon(this.getClass().getResource(iconName));
}
The function getImageIcon is the one that needs to retrieve the pictures.
thnx