1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public void paintComponent(Graphics g){
if(kind.equals("go")||kind.equals("go_to_jail")||kind.equals("jail")||kind.equals("free_parking")){
this.setPreferredSize(new Dimension(170,170));
this.revalidate();
this.repaint();
if(kind.equals("go")){
g.drawImage(new ImageIcon("img/go.jpg").getImage().getScaledInstance(170,170,Image.SCALE_DEFAULT), 0, 0, this);
}
else if(kind.equals("go_to_jail")){
g.drawImage(new ImageIcon("img/gotojail.jpg").getImage().getScaledInstance(170,170,Image.SCALE_DEFAULT), 0, 0, this);
}
else if(kind.equals("jail")){
g.drawImage(new ImageIcon("img/justvisiting.jpg").getImage().getScaledInstance(170,170,Image.SCALE_DEFAULT), 0, 0, this);
}
else{
g.drawImage(new ImageIcon("img/freeparking2.jpg").getImage().getScaledInstance(170,170,Image.SCALE_DEFAULT), 0, 0, this);
}
}
else if(kind.equals("community_chest")||kind.equals("chance")){
if(kind.equals("community_chest")){
g.drawImage(new ImageIcon("img/community_chest.gif").getImage().getScaledInstance(100,100,Image.SCALE_DEFAULT),10,10,this);
}
else {
g.drawImage(new ImageIcon("img/chance.gif").getImage().getScaledInstance(100,100,Image.SCALE_DEFAULT),0,0,this);
}
this.repaint();
} |
Partager