I’m new here (this is my first post) and a pretty big noob, just started programming and working with tutorials along with reading on Java, but I’m having an issue getting an image onto a button. I’m making a puzzle game that creates 12 cropped squares of an image that you can shuffle around to form the original picture.
Here’s the part I’m having problems with.
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
if (j == 2 && i == 3) {
label = new JLabel();
centerPanel.add(label);
} else {
button = new JButton();
button.addActionListener(this);
centerPanel.add(button);
image = new createImage(new FilteredImageSource(source.getSource(),
new CropImageFilter(j * width / 3, i * height / 4, (width / 3) + 1, height / 4)));
button.setIcon(new ImageIcon(image));
}
}
}
the image = new createImage() part is telling me createImage() doesn’t exist. Am I forgetting to import anything or am I calling and/or passing the wrong stuff?
any help would be much appreciated.
Thanks!