Im creating a Chess game. Im stuck at getting the pieces to move within the rules Aka bishop can only move diagonally.
I Create Panels - 64 of them within a lager panel then add JLabels - The pieces - into those panels
JLabel bb = new JLabel(new ImageIcon("bb.gif"));
panel = (JPanel)chessBoard.getComponent(2);
Thats how I add the piece into the panel on the board but when I try this on Mouse event e :
Component squareNumber = chessBoard.findComponentAt(e.getX(), e.getY());
and then i Print squareNumber i get
How can I get a number 1-64 to print out?(aka how can i figure out which component that piece is in)