I have a grid of 16 buttons which will represent dice. When a score is added, I want a JLabel to pop up in the middle and display the added score. The 16 buttons and one label are all within one JLabel. Why do the buttons always show on top of the JLabel, even when the JLabel is set to visible?
Thank you for any help!
Pictures
JButtons visible, JLabel is not:
When the JButtons are setVisible to false, the JLabel is seen:
Code
Here is the constructor to my code. The label does not show up if the buttons are visible.
public Grid()
{
super();
setLayout(null);
setBounds(125,205,290,290);
setBackground(new Color(139,69,19));
setBorder(new LineBorder(Color.black,5));
for(int a = 0; a < piece.length; a ++)
{
for(int b = 0; b < piece[0].length; b ++)
{
piece[a][b] = new DiceButton(0,0,a,b,null);
piece[a][b].addActionListener(this);
add(piece[a][b]);
}
}
scoringVisual = new JLabel("+ 200");
scoringVisual.setBounds(110, 135, 70, 30);
scoringVisual.setFont(new Font("Arial Rounded MT Bold", Font.BOLD, 20));
scoringVisual.setOpaque(true);
scoringVisual.setBackground(new Color(0,87,0));
scoringVisual.setForeground(new Color(38,224,2));
scoringVisual.setHorizontalAlignment(JLabel.CENTER);
scoringVisual.setBorder(new LineBorder(Color.black,1));
add(scoringVisual);
}