0

Is that possible. I tried setting opacity of the Jframe and set background but it didn't work out. Is there some easy and elegant way?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
The1NOnly
  • 9
  • 2

1 Answers1

1

You can achieve this by setting the JFrame’s glassPane to a visible JPanel with a translucent background:

static void setDimmed(JFrame frame,
                      boolean dimmed) {

    JComponent newGlassPane = new JPanel();
    if (dimmed) {
        newGlassPane.setBackground(new Color(0x80000000, true));
    }
    frame.setGlassPane(newGlassPane);
    newGlassPane.setVisible(dimmed);
}
VGR
  • 40,506
  • 4
  • 48
  • 63