在Java教程表明这是可以实现的一种方式。这是使用RGBA(红色,绿色,蓝色,alpha)值作为背景色的另一种方法:
public class Overlay { public static void main(String[] args) { Jframe frame = new Jframe("Transparent Window"); frame.setUndecorated(true); frame.setBackground(new Color(0, 0, 0, 0)); frame.setAlwaysonTop(true); // Without this, the window is draggable from any non transparent // point, including points inside textboxes. frame.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", false); frame.getContentPane().setLayout(new java.awt.BorderLayout()); frame.getContentPane().add(new JTextField("text field north"), java.awt.BorderLayout.NORTH); frame.getContentPane().add(new JTextField("text field south"), java.awt.BorderLayout.SOUTH); frame.setVisible(true); frame.pack(); }}


