早上好,我正在實現一個遊戲的GUI,當我玩遊戲的時候,我得到了無數的這個例外隨後的比賽凍結,上有什麼問題或如何解決它是非常讚賞at java.awt.AWTEventMulticaster.mouseExited(Unknown Source)多次使用GUI後出現
這裏的任何幫助代碼:
public class BoardFrame extends JFrame implements MouseListener {
private void boardWithoutCheckers() {
for(int i=0; i<8; i++) {
for(int j=0; j< 8; j++) {
if(((i + j) % 2) == 0){
boardFrame[i][j] = new LightGrayButton();
}
else {
boardFrame[i][j] = new DarkGrayButton();
}
boardFrame[i][j].addMouseListener(this);
this.getContentPane().add(boardFrame[i][j]);
}
}
this.setVisible(true);
}
@Override
public void mouseClicked(MouseEvent e) {
count++;
if(count == 1){
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if(e.getSource().equals(boardFrame[i][j])){
possibleMoves = board.getPossibleMoves(new Point(j,i));
for (int k = 0; k < possibleMoves.size(); k++) {
Point temp = new Point(possibleMoves.get(k).getX(),possibleMoves.get(k).getY());
boardFrame[temp.getY()][temp.getX()].setBackground(new Color(99,204,94,50));
}
firstClick = new Point(j, i);
break;
}
}
}
}
if(count == 2){
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if(e.getSource().equals(boardFrame[i][j])){
for (int k = 0; k < possibleMoves.size(); k++) {
if(possibleMoves.get(k).getX() == j && possibleMoves.get(k).getY() == i){
if(board.getTurn() == 1){
boardFrame[i][j].setIcon(null);
boardFrame[i][j].setIcon(new ImageIcon(Earth));
boardFrame[firstClick.getY()][firstClick.getX()].setIcon(null);
board.move(firstClick, new Point(j,i));
}
else if(board.getTurn() == 2){
boardFrame[i][j].setIcon(null);
boardFrame[i][j].setIcon(new ImageIcon(Mars));
boardFrame[firstClick.getY()][firstClick.getX()].setIcon(null);
board.move(firstClick, new Point(j,i));
break;
}
}
}
}
}
}
count=0;
possibleMoves = new ArrayList<Point>();
for(int i=0; i<8; i++) {
for(int j=0; j< 8; j++) {
if(((i + j) % 2) == 0){
boardFrame[i][j].setBackground(new Color(15, 81, 162));
}
else {
boardFrame[i][j].setBackground(new Color(77, 77, 77));
}
boardFrame[i][j].addMouseListener(this);
}
}
}
if(board.isGameOver()){
JLabel winner = new JLabel("we have a winner");
this.getContentPane().add(winner);
}
}
唯一的例外按摩我只得到了無數的它 at java.awt.AWTEventMulticaster.mouseExited(Unknown Source)
Im相當肯定的是,板類是100%,因爲它是由我們大學的助教提出並通過了所有的測試
在此先感謝
很可能問題在於你沒有向我們展示的代碼,比如你的Board類。請顯示您的完整例外消息。請指出哪一行引發異常。 – 2013-05-09 15:28:14
唯一例外的消息我得到的是\t 在java.awt.AWTEventMulticaster.mouseExited(來源不明) 但它的無數 也關於董事會類即時通訊相當肯定它是正確的,因爲在我們的大學老師助手實施它併成功通過所有測試的人 – cdLegend 2013-05-09 15:44:38
請考慮創建併發布[sscce](http://sscce.org)(請參閱鏈接)。 – 2013-05-09 15:48:23