Javaチュートリアルは、これを実現する1つの方法を示しています。背景色にRGBA(赤、緑、青、アルファ)値を使用する別のアプローチは次のとおりです。
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();
}
}