学習プログラムのプロジェクトとして、倉庫番のクローンをプログラムしました。JDK 7 にアップグレードしてから、次の問題があります。JPanel
初めて repaint() メソッドを呼び出すとすぐに、JPanel の右側に「影の画像」が次のように表示されます
。
何が原因なのかわからないので、どのコードを追加すればよいかわかりません。paint() メソッドは次のとおりです。
public void paint(Graphics g) {
int x;
int y;
// draw column
for (int k = 0; k < field.getField().length; k++) {
y = (tileWidth * k); // Get y coordinate
// draw line
for (int l = 0; l < field.getField()[0].length; l++) {
FieldObj now = field.getField()[k][l];
x = (tileWidth * l); // Get x coordinate
// Wall
if (now instanceof Wall)
g.drawImage(Wall, x, y, tileWidth, tileWidth, null);
// Box
else if (now instanceof Box && ((Box) now).getStandingOnGoal())
g.drawImage(BoxOnG, x, y, tileWidth, tileWidth, null);
else if (now instanceof Box)
g.drawImage(Box, x, y, tileWidth, tileWidth, null);
// Man on Goal
else if (now instanceof Man
&& field.getMan().getStandingOnGoal()
&& field.getMan().getOr() == 0)
g.drawImage(ManGU, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man
&& field.getMan().getStandingOnGoal()
&& field.getMan().getOr() == 1)
g.drawImage(ManGL, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man
&& field.getMan().getStandingOnGoal()
&& field.getMan().getOr() == 2)
g.drawImage(ManGR, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man
&& field.getMan().getStandingOnGoal()
&& field.getMan().getOr() == 3)
g.drawImage(ManGD, x, y, tileWidth, tileWidth, null);
// Man
else if (now instanceof Man && field.getMan().getOr() == 0)
g.drawImage(ManU, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man && field.getMan().getOr() == 1)
g.drawImage(ManL, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man && field.getMan().getOr() == 2)
g.drawImage(ManR, x, y, tileWidth, tileWidth, null);
else if (now instanceof Man && field.getMan().getOr() == 3)
g.drawImage(ManD, x, y, tileWidth, tileWidth, null);
// Floor
else if (now instanceof Floor && ((Floor) now).getGoal())
g.drawImage(Goal, x, y, tileWidth, tileWidth, null);
else
g.drawImage(Floor, x, y, tileWidth, tileWidth, null);
}
}
}
助言がありますか?見たい他のコードはありますか?どんな助けにも感謝します。あ