トピックとして私は最初の2Dゲームとしてチェスゲームを作成しましたが、これから実行可能なjarファイルを作成しようとすると、奇妙な行動、そして私が作品を動かすと、ゲームは混沌となり、何も働かない。奇妙なことは、すべてが完全に機能することです。私はそれが隠しファイルやシステムファイルだと思いますので、私も私のプロジェクトでは、このようなファイルを持って覚えていない私のChessプロジェクトのeclipseでrunnable jarファイルを作成するときに奇妙な動作が起こる
Resource is out of sync with the file system: '/Chess_Project/src/.DS_Store'.
:それは実行可能なjarファイル日食を作成すると、次のエラーが発生します。それから、通常のJarファイルとしてeclipseを使ってエクスポートしてみましたが、ターミナル経由で(Mac OSXのlionユーザーでは)、私は両方の方法で失敗し、NullPointerException
といくつかのエラーが出ました。私はマニフェストファイルについて少し読んで、自分でコードをコンパイルして、上で述べたそれぞれの方法でエクスポートしようとしました。
私は1週間ほどそれを解決しようとしていて、さまざまなフォーラムで助けを求めましたが、運がありません。
フランシスのおかげで、私のコード自体から問題が発生する可能性があります。そして、私の質問はです。なぜ、実行可能なjarファイルに異常な動作が起こるのですか?。 がここに私のコードのメインクラスである:人々がここにそんなに早く返事のは驚くべきことであるところで
import java.awt.*;
import javax.swing.SwingUtilities;
import javax.swing.*;
public class MainWindowChess {
/**
*
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
JFrame f = new JFrame("Chess");
SwingUtilities.isEventDispatchThread();
f.setLayout(new BorderLayout());
f.setSize(40 * 8, 40 * 9 - 20);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(false);
Board b = new Board();
f.add(b);
f.setVisible(true);
System.out.println("check");
}
});
}
}
、私は他の人を助けたいので、多くの人を見て嬉しく思います。ここで
はpaintComponentメソッドです:
protected void paintComponent(Graphics g) {
super.paintComponents(g);
if (boardDrawn == false) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
g.drawImage(getRect(i, j), cors[i][j].getXCor(), cors[i][j].getYCor(), null);
}
}
for (int i = 0; i < bp.length; i++) {
bp[i].drawPiece(g, bp[i].getImage(), bp[i].getLocationX(), bp[i].getLocationY());
}
for (int i = 0; i < wp.length; i++) {
wp[i].drawPiece(g, wp[i].getImage(), wp[i].getLocationX(), wp[i].getLocationY());
}
boardDrawn = true;
} else if (boardDrawn == true) {
if (tempPiece instanceof BlackPiece) {
for (int i = 0; i < bp.length; i++) {
//if the piece was found
if (tempPiece == bp[i]) {
if (bp[i].isMoveAvailable(bp[i].getTypeID(), bp[i].getLocationX(), bp[i].getLocationY(), tempCor.
getXCor(), tempCor.getYCor())) {
killTime = true;
//if the rectangle which we want to draw the Piece on is not occupied by another Piece
if (isRectBlocked(bp[i].getTypeID(), oldCor.getXCor(), oldCor.getYCor(), tempCor.
getXCor(), tempCor.getYCor()) == false) {
g.drawImage(getCompatitableRect(oldCor.getXCor(), oldCor.getYCor()), oldCor.
getXCor(), oldCor.getYCor(), null);
bp[i].drawPiece(g, bp[i].getImage(), tempCor.getXCor(), tempCor.getYCor());
bp[i].setX(tempCor.getXCor());
bp[i].setY(tempCor.getYCor());
} else if (canRectBeOccupied(bp[i], tempCor.getXCor(), tempCor.getYCor())
&& isRectBlocked(bp[i].getTypeID(), oldCor.getXCor(), oldCor.getYCor(), tempCor.
getXCor(), tempCor.getYCor()) == false) {
g.drawImage(getCompatitableRect(oldCor.getXCor(), oldCor.getYCor()), oldCor.
getXCor(), oldCor.getYCor(), null);
g.drawImage(getCompatitableRect(tempCor.getXCor(), tempCor.getYCor()), tempCor.
getXCor(), tempCor.getYCor(), null);
bp[i].drawPiece(g, bp[i].getImage(), tempCor.getXCor(), tempCor.getYCor());
bp[i].setX(tempCor.getXCor());
bp[i].setY(tempCor.getYCor());
}
}
}
}
}
if (tempPiece instanceof WhitePiece) {
for (int i = 0; i < wp.length; i++) {
//if the piece was found
if (tempPiece == wp[i]) {
if (wp[i].isMoveAvailable(wp[i].getTypeID(), wp[i].getLocationX(), wp[i].getLocationY(), tempCor.
getXCor(), tempCor.getYCor())) {
killTime = true;
if (isRectBlocked(wp[i].getTypeID(), oldCor.getXCor(), oldCor.getYCor(), tempCor.
getXCor(), tempCor.getYCor()) == false) {
System.out.println("");
g.drawImage(getCompatitableRect(oldCor.getXCor(), oldCor.getYCor()), oldCor.
getXCor(), oldCor.getYCor(), null);
wp[i].drawPiece(g, wp[i].getImage(), tempCor.getXCor(), tempCor.getYCor());
wp[i].setX(tempCor.getXCor());
wp[i].setY(tempCor.getYCor());
} else if (canRectBeOccupied(wp[i], tempCor.getXCor(), tempCor.getYCor())
&& isRectBlocked(wp[i].getTypeID(), oldCor.getXCor(), oldCor.getYCor(), tempCor.
getXCor(), tempCor.getYCor()) == false) {
g.drawImage(getCompatitableRect(oldCor.getXCor(), oldCor.getYCor()), oldCor.
getXCor(), oldCor.getYCor(), null);
g.drawImage(getCompatitableRect(tempCor.getXCor(), tempCor.getYCor()), tempCor.
getXCor(), tempCor.getYCor(), null);
wp[i].drawPiece(g, wp[i].getImage(), tempCor.getXCor(), tempCor.getYCor());
wp[i].setX(tempCor.getXCor());
wp[i].setY(tempCor.getYCor());
}
}
}
}
}
killTime = false;
tempPiece = null;
}
}
.DS_Storeは、バックアップに関してOS Xが生成するファイルです。jarファイルには含めないでください。完全なNullPointerを投稿してください。 – rooftop
プロジェクトを更新しようとしましたが、[Resource Out of Sync](http://pisceansheart.wordpress.com/2008/08/28/how-to-fix-resource-is-out-of-sync -with-the-file-system-in-eclipse /)? –
*「奇妙なことです..」* ..これはQ&Aサイトであり、あなたは質問をしていません。 * "さまざまなフォーラムで尋ねられました" *あなたの質問に質問が含まれていない場合、なぜあなたが答えを得なかったのか理解しています。 - あなたの質問は何ですか? –