I figured out what I did wrong. This:
background.setIcon(new ImageIcon(getClass().getResource("spaceage.images.starfield.png")));
needed to be changed to this:
background.setIcon(new ImageIcon(getClass().getResource("/spaceage/images/starfield.png")));
I got a NullPointerException
because I entered the path to my image incorrectly, so getResource()
couldn't find the image and returned null
.