I'm trying to create a simple Card class that extends BufferedImage so I can draw the card directly on the screen. But the card has two faces. The front, and the back. I am including a flip(boolean faceup) method that I want to change the image from one side to the next, but it seems that since the Class extends BufferedImage, it's final? I'm not sure, that's my impression. It doesn't change from the original image drawn in the constructor. Is there any way around this so I can still paint the card directly on-screen? This is what I have so far...
public Card(int rank, int suit)
{
super(50,70,TYPE_INT_ARGB);
this.rank = rank;
this.suit = suit;
try{bi = ImageIO.read(getClass().getResource(toString()+".png"));
back = ImageIO.read(getClass().getResource("back.png"));}
catch(IOException e){e.printStackTrace();}
Graphics2D g = createGraphics();
g.drawImage(back,0,0,null);
g.dispose();
}
public void flip(boolean faceup)
{
this.faceup = faceup;
Graphics2D g = createGraphics();
if(faceup)g.drawImage(bi,0,0,null);
else g.drawImage(back,0,0,null);
g.dispose();
}