Before you read, here are some clarifications about the question:
- SSCCE is for Java 7. You could use sun. * AWTUtilities to adapt it to Java 6, but I don’t care how it works in Java 6.
- The fault line [...] is
new JDialog(someWindow) . Phantom can be fixed in SSCCE by simply changing that line to [...]new JDialog() .
Why aren't top-level windows with a halo displayed?
Expected Behavior: final JDialog d = new JDialog() (see SSCCE) 
As you can see, the right window has a translucent background (as expected).
Actual behavior: final JDialog d = new JDialog(f) (see SSCCE) 
In this case, the right window has an opaque background. Essentially, for some reason, 3-4 peer reviews are required (the easiest way to reproduce the redraw when rolling over) is for the background to become completely opaque.
SSCCE:
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.plaf.synth.ColorType; import javax.swing.plaf.synth.Region; import javax.swing.plaf.synth.SynthConstants; import javax.swing.plaf.synth.SynthContext; import javax.swing.plaf.synth.SynthLookAndFeel; import javax.swing.plaf.synth.SynthPainter; import javax.swing.plaf.synth.SynthStyle; import javax.swing.plaf.synth.SynthStyleFactory; public class SynthSSCCE { public static void main(String[] args) throws Exception { final SynthLookAndFeel laf = new SynthLookAndFeel(); UIManager.setLookAndFeel(laf); SynthLookAndFeel.setStyleFactory(new StyleFactory()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final JFrame f = new JFrame(); { f.add(new JButton("Works properly")); f.setUndecorated(true); f.setBackground(new Color(0, true)); f.setSize(300, 300); f.setLocation(0, 0); f.setVisible(true); } { final JDialog d = new JDialog(f); final JButton btn = new JButton("WTF?");
And these are my questions ...
- What's happening? As in, why does this demonstrate the behavior of a personalized opaque component that forgets to call super?
- Why does this not happen with TL windows?
- What is the easiest way to fix this other than using non-TL windows?
java user-interface swing jwindow synth
afk5min
source share