Odd behavior with transparent window getting shadow after toggling	visibility
    AJ Gregory 
    ajgregory at gmail.com
       
    Tue Nov 25 19:47:04 UTC 2014
    
    
  
If you run the class below on a RETINA MacBook Pro (OSX 10.10) the first
time you see the JWindow it's a white circle with NO shadow, but then later
when it calls setVisible(false) and setVisible(true) the circle has a
shadow when it's made visible again which isn't right...
I can't reproduce on non-retina (OSX 10.9) so wondering if it's a retina
only issue?
Same behavior for both Java 7u71 and 8u25...
Anybody else experience this and have a work around?
Seems like a bug for sure unless I'm missing something...
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TestMacShadow {
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                final JWindow window = new JWindow() {
                    public void paint(Graphics g) {
                        g.setColor(Color.WHITE);
                        g.fillOval(0, 0, getWidth(), getHeight());
                    }
                };
                window.setBackground(new Color(0, 0, 0, 0));
                window.setLocation(new Point(100, 100));
                window.setSize(new Dimension(300, 300));
                window.setAlwaysOnTop(true);
                window.setVisible(true);
                Timer t = new Timer(2000, new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        window.setVisible(!window.isVisible());
                    }
                });
                t.setRepeats(true);
                t.start();
            }
        });
    }
}
    
    
More information about the macosx-port-dev
mailing list