import java.awt.*;
import java.util.*;
import javax.swing.*;
public class Mole extends JButton{
private static final int MIN = 50;
private static final int MAX = 300;
static Random rand = new Random(); //declare Random statically so it does not have to be re-initiated for each use
private boolean up; //shows whether creature is alive or not
private int remaining_life; //shows how long the creature has currently been alive if applicable
private int zero_lives; //stores how long the creature will be alive for this life
public Mole() {
up = false;
this.setBackground(Color.RED);
remaining_life = 0;
}
我可以使用setBackground
将颜色更改为红色。但是,如果我想使用图像而不是颜色呢?