Hi,
I have encountered a problem with the transparency of JInternalFrames in a program
when I set the Nimbus look and feel. What I want is to have semitransparent
JInternalFrames and I do this by setting their opaque attribute to false and
choosing a background color that has a non zero alpha component for their
JDesktopPane:
JInternalFrame internalFrame = new JInternalFrame("Workspace Window", true);
JDesktopPane desktopPane = new JDesktopPane();
internalFrame.setOpaque(false);
int rgb = 0x46B4DCB4;
Color c = new Color(rgb, true);
desktopPane.setBackground(c); //
And this works fine with the classical Metal look and Feel, everything looks nice and
there are no problems. But when I use
UIManager.setLookAndFeel(Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"))
the JInternalFrames appear totally opaque.
Now I know that Nimbus gets uses the properties in UIManager to set the graphical
attributes and I tried to customize these properties like this:
UIManager.put("nimbusBase", new Color(0x00, 0xAA, 0xFF, 0x40));
UIManager.put("DesktopPane.background", new Color(0, 255, 0, 100));
UIManager.put("DesktopPane.foreground", new Color(0, 255, 0, 100));
UIManager.put("DesktopPane.opaque", false);
UIManager.put("InternalFrame.foreground", new Color(180, 180, 220, 100));
UIManager.put("InternalFrame.background", new Color(180, 180, 220, 100));
UIManager.put("InternalFrame.opaque", false);
UIManager.put("InternalFrame.ContentPane.opaque", false);
UIManager.put("InternalFrame.ContentPane.background", new Color(255, 0, 0, 100));
UIManager.put("InternalFrame.RootPane.opaque", false);
UIManager.put("InternalFrame.RootPane.background", new Color(255, 255, 255, 100));
UIManager.put("RootPane.background", new Color(255, 255, 255, 100));
UIManager.getDefaults().remove("DesktopPane[Enabled].backgroundPainter");
UIManager.getDefaults().remove("InternalFrame[Enabled].backgroundPainter");
There are visible effects like the change of the colors used to paint the title bars and the
panels' backgrounds as well as the disappearance of the image painted on the panels by
the backgroundPainters.
However the only transparency I get is in the borders of the disabled JInternalFrames.
I even left the JInternalFrame with its default content panel, but in this case it just appears
with an opaque gray background. I have not succeeded in making the JDesktopPane
transparent on Nimbus.
Does anyone have any tip, am I missing something or is this just another bug / limitation
of Nimbus?
Thanks.