- #1
BiGyElLoWhAt
Gold Member
- 1,624
- 132
Here's the snippet I'm erroring on. I'm sure I have a bad syntax or I'm not relative referencing correctly or something. Null pointer.
Basically I just want to load in my images to an array to be referenced later. It's for a tic tac toe game. 2 players, 2 styles of x's and o's.
I have:
workspace -> project 2 -> img -> (png files)
I pretty much ripped this off stack exchange, and that is how the user was referencing their images, except with 2 slashes. I tried changing that. It didn't do anything. Same error. Am I referencing improperly? Or am I doing something wrong in the ImageIcon?
*edit
http://stackoverflow.com/questions/17110315/jbutton-background-image
this is where I got the code from
Java:
xo = new ImageIcon[2][2];
xo[0][0] = new ImageIcon(getClass().getResource("img/x1.png"));
xo[0][1] = new ImageIcon(getClass().getResource("img/o1.png"));
xo[1][0] = new ImageIcon(getClass().getResource("img/x2.png"));
xo[1][1] = new ImageIcon(getClass().getResource("img/o2.png"));
player = 0;
style = 0;
setOpaque(true);
Basically I just want to load in my images to an array to be referenced later. It's for a tic tac toe game. 2 players, 2 styles of x's and o's.
I have:
workspace -> project 2 -> img -> (png files)
I pretty much ripped this off stack exchange, and that is how the user was referencing their images, except with 2 slashes. I tried changing that. It didn't do anything. Same error. Am I referencing improperly? Or am I doing something wrong in the ImageIcon?
*edit
http://stackoverflow.com/questions/17110315/jbutton-background-image
this is where I got the code from
Last edited by a moderator: