As the title, I have this code:
protected void paintComponent(Graphics g) {
Image image = Toolkit.getDefaultToolkit().getImage("image.png");
g.drawImage(image, getWidth(), getHeight(), this);
}
Now I want to change the image whenever I click a JButton
.
Is there anyway to change the image in paintComponent
when JButton
is clicked?