Lindy Kron
Lindy Kron

Reputation: 43

Semi-opaque jPanels

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));

}

Upvotes: 1

Views: 81

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285460

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.

Upvotes: 3

Related Questions