By Alvin Alexander. Last updated: June 6, 2016
I just tried a quick test of transparency/translucency on Mac OS X using Java, and in short, here is the source code I used to create a transparent/translucent Java JFrame on Mac OS X 10.9:
package demo; import javax.swing.*; import java.awt.BorderLayout; import java.awt.Dimension; /** * Creates a transparent/translucent Java JFrame on Mac OS X. * @author alvin alexander, http://alvinalexander.com */ public class MacTranslucentFrame { public static void main(String[] args) { new MacTranslucentFrame(); } public MacTranslucentFrame() { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame editorFrame; editorFrame = new JFrame("Java Mac OS X Translucency Demo"); editorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // this is what sets the transparency/translucency on Mac OS X editorFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.2f)); editorFrame.setUndecorated(true); editorFrame.setPreferredSize(new Dimension(1200, 900)); editorFrame.setMinimumSize(new Dimension(1200, 900)); editorFrame.pack(); editorFrame.setLocation(10,10); editorFrame.setVisible(true); } }); } }
This code creates a 1200x900 pixel Java JFrame that is 80% transparent, letting you see your desktop and anything else that is behind it.