I am trying to make 2 jPanels appear and be opaque after a button click. This mostly works. Both panels appear and are opaque, however they both have the button appear within them. The extra buttons only disappear when I change the screen size (minimize or Maximize). Could someone please tell me what I am doing wrong.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel2.setOpaque(true);
jPanel2.setBackground(new Color(51, 255, 51, 100));
jPanel3.setOpaque(true);
jPanel3.setBackground(new Color(51, 255, 51, 50));
}
Don’t forget to call
repaint()on the container holding the JPanels or the JPanels themselves after changing the JPanel’s opacity. Until the panels are repainted, you will not see any changes.