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); panel.add(bb);
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
javax.swing.JPanel[,300,0,75x75,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
How can I get a number 1-64 to print out?(aka how can i figure out which component that piece is in)