Due problems in showing JAVA 6 Splash screen i used following method to show a splash window.
File splashImageFile = new File(Constants.PATH_IMAGE + "splash.png");
final BufferedImage img = ImageIO.read(splashImageFile);
final JWindow window = new JWindow() {
private static final long serialVersionUID = -132452345234523523L;
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Rectangle windowRect = getBounds();
try {
Robot robot = new Robot(getGraphicsConfiguration().getDevice());
BufferedImage capture = robot.createScreenCapture(new Rectangle(windowRect.x, windowRect.y, windowRect.width, windowRect.height));
g2.drawImage(capture, null, 0, 0);
} catch (IllegalArgumentException iae) {
System.out.println("Argumets mis matched.\n" + iae.getMessage());
} catch(SecurityException se){
System.out.println("Security permission not supported\n" + se.getMessage());
} catch (AWTException ex) {
System.out.println("Exception found when creating robot.\n" + ex.getMessage());
}
g2.drawImage(img, 0, 0, null);
g2.setFont(new Font("TimesRoman", Font.BOLD, 15));
g2.drawString("Loading...", 320, 260);
g2.dispose();
}
};
window.setAlwaysOnTop(true);
window.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
window.repaint();
The image is png transparent image as i need rounded cornered rectangle shape in my window. It works on Win 7 but in mac 10.8. Mac still shows rectangle shape background. It does not seems as background either actually. Can someone tell me what may cause to that. Following are the images for each platform.
On windows

On mac

Thanks in advance.
EDIT:
Answers are great but I’ve seen that AWTUtilities is not always getting system support. So in some some systems answered methods may fail. Isn’t there a solution much formal? I mean solution comes from the basic level?
To get an uniform solution, you should use Java7. Per pixel translucency was nearly an “experimental” feature in Java 6, and not thought to be something you could rely on (that’s why AWTUtilities was into the com.sun package, which is not part of Java public API).
However, and although I haven’t got a Mac to test it, I’ve seen people reporting that setting the frame background to Color(0, 0, 0, 0) (last parameter is the alpha channel) worked for them in MacOS. I do not remember clearly if it worked in windows (I had to use it a couple of years ago), but I’ve just tested it in Linux and it doesn’t.
In Java 7, translucent windows are fully supported and working flawlessly in Windows, MacOS and Linux. JFrame has the new setOpacity(Alpha) method (that works only with undecorated frames) and setColor(new Color(R, G, B, Alpha)) is also working (it’s equivalent, and again only working with undecorated frames).
As you can see, you can’t rely on the private API AWTUtilities. In Java 6 you haven’t got any “formal solution” for this problem, only hacks, private APIs and uncertainty… I don’t know if it is an option, but you should think about switching to Java7 if you can.