Is there a way for me to add buttons to the right side of my JLayeredPane? The layered pane contains a JPanel which represents a chess board and on top of this board I have JLabels representing chess pieces. I want basically another panel attached to the right side of the board which contains player information and buttons allowing for rematches/etc. What would be the best way to go about adding this panel?
Here is a snippet of my code. The part which sets up the board panel inside the layeredpane:
private void setupBoard() {
paneX = new JLayeredPane();
getContentPane().add(paneX);
paneX.setPreferredSize(new Dimension(500,500));
boardX = new JPanel();
paneX.add(boardX, JLayeredPane.DEFAULT_LAYER);
boardX.setLayout(new GridLayout(8,8));
boardX.setBounds(0,0,500,500);
chessBoard.setPreferredSize(new Dimension(500,500));
}
Then, I go on to add the jlabels to each component on the panel. I want to add another big panel attached to the right side of the board like I mentioned earlier.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…