Reputation: 21
I have a modal JDialog
that I set non-opaque with a call to the com.sun.awt.AWTUtilities
method, setWindowOpaque(this, false)
.
I encounter problems when I set the modal JDialog
to be non-opaque. For example, when I click on a button a non-opaque dialog, it pop up correctly but after a couple of opening and closing of the dialog, it does open. It is not visible; and, since it is modal, we can't click on the button contained in the parent panel. It's like it is frozen, but that's only because of the modal dialog.
If I remove the call to the method setWindowOpaque(this, false)
, it works without any problem.
Does anyone know what is going on?
I am using Java version "1.6.0_26" on Windows XP.
Thanks.
Upvotes: 2
Views: 2549
Reputation: 11873
Ok, had a similar problem, sometimes the window was not responding, or transparency was broken... weird problems.
The solution, at least for me, was calling new TransparentWindow()
inside invokeLater
:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
TransparentWindow w = new TransparentWindow();
w.setVisible(true);
}
});
TransparentWindow is a class extending JWindow that uses com.sun.awt.AWTUtilities.setWindowOpaque(window,false);
to create a transparent window with rounded transparent corners as explained here: Soft clipping and per-pixel translucency for Swing windows
Upvotes: 1