I am trying to build a toolbar for this math practice program that I wrote. I am trying to get an image from a folder called images. It will not allow me to. It gives me a NullPointerException, I will mark the lines with * where the Exception points to.
public JButton makeNavigationButton( String imageName, String toolTipText ) {
String imgLocation = "images/" + imageName + ".jpg";
URL imageURL = MathPractice.class.getResource(imgLocation);
JButton button = new JButton();
button.setToolTipText(toolTipText);
//button.addActionListener(this);
button.setIcon( new ImageIcon( imageURL )); //************* NPE here
return button;
}