給你發個透明窗口的例子...
public class TranslucentWindow extends JFrame { public TranslucentWindow() { super("TranslucentWindow"); setLayout(new GridBagLayout()); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(new JButton("I am a Button"));//設置窗口的透明度為 55% AWTUtilities.setWindowOpacity(this, 0.55f); } public static void main(String[] args) { //如果當前JDK不支持透明則退出 if (!AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) { System.err.println("Translucency is not supported"); System.exit(0); } TranslucentWindow tw = new TranslucentWindow(); tw.setVisible(true); }
}</pre>
本文由用戶 灬猜想灬 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!