private class Painter extends JPanel {
private Painter() {
xloc = 300;
yloc = 300;
whatToChange = -1;
}
public void paint(Graphics g) {
Image player;
if (whatToChange == -1) {
player = tools.getImage("pic/stickSprite/standing");
} else if (whatToChange == 0) {
player = tools.getImage("pic/stickSprite/usingleft");
} else if (whatToChange == 1) {
player = tools.getImage("pic/stickSprite/usingright");
} else if (whatToChange == 2) {
player = tools.getImage("pic/stickSprite/left");
xloc += 20;
} else if (whatToChange == 3) {
player = tools.getImage("pic/stickSprite/right");
xloc -= 20;
} else if (whatToChange == 4) {
player = tools.getImage("pic/stickSprite/climbingleft");
xloc += 20;
yloc += 20;
} else {
player = tools.getImage("pic/stickSprite/climbingright");
xloc -= 20;
yloc += 20;
} //TODO falling
g.drawImage(player, xloc, yloc, 60, 30, this);
}
}
}
WHen I create a new Painter object, add it to the JFrame, and call its repaint method, it doesn't show the image!


Sign In
Create Account


Back to top









