// If we're holding a piece, clear the hover of the cell if(heldI >= 0 && heldX >= 0) { ClearHlight(heldI, heldX); }
switchPlayer();
heldX = heldY = heldI = -1; }
private void buildBoard() { // First reset the variables, maps, etc. resetBoard();
int rowColor = 0; int i = 0; for(int x = 0; x <= 7; x++) { rowColor++; for(int y = 0; y <= 7; y++) { lblCells[i] = new JLabel("", JLabel.CENTER); lblCells[i].setOpaque(true); if(rowColor % 2 == 0) { lblCells[i].setBackground(Color.GRAY); } else { lblCells[i].setBackground(Color.WHITE); }
final int passX = x; final int passY = y; final int passI = i;
lblCells[i].addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent e) { // If we're holding a piece show that along with the cell we're hovering if(heldI > 0) { lblStatus.setText("Picked up " + pieceName.get(jPieces[heldX][heldY]) + " at " + showBoardRelative(heldX, heldY) + " | Hovering: " + showBoardRelative(passX, passY)); } else // Just show what we're hovering { lblStatus.setText("Hovering: " + showBoardRelative(passX, passY)); } // Unless we hover the one we're holding... if(passI != heldI) { lblCells[passI].setBackground(Color.DARK_GRAY); } } });
lblCells[i].addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent e) { lblStatus.setText(""); // Unless we hover the one we're holding... if(passI != heldI) { // Clear the hover effect ClearHlight(passI, passX); } } });
/** * This method initializes btnNewGame * * @return javax.swing.JButton */ private JButton getBtnNewGame() { if (btnNewGame == null) { btnNewGame = new JButton(); btnNewGame.setText("New Game"); btnNewGame.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent e) { if(JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, "Are you sure you wish to end this game?")) { newGame(); } } }); } return btnNewGame; }
}
Arkadaşlar bu kodda şu hatayı veriyor
Exception in thread "main" java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(ImageIO.java:1348) at newsatranc.NewSatranc.PaintPiece(NewSatranc.java:200) at newsatranc.NewSatranc.RepaintPieces(NewSatranc.java:225) at newsatranc.NewSatranc.resetPieces(NewSatranc.java:190) at newsatranc.NewSatranc.buildBoard(NewSatranc.java:362) at newsatranc.NewSatranc.<init>(NewSatranc.java:76) at newsatranc.NewSatranc.main(NewSatranc.java:99)
Sanırım imageleri yükleyemiyorum.Bir kaç farklı yol ile denedim ve image adresini de değiştirdim ama sonuç aynı.Yardım olabilecek varsa çok makbule geçer.