Swing/WindowOpacity のバックアップ差分(No.3)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/WindowOpacity へ行く。
- 1 (2010-06-14 (月) 14:13:21)
- 2 (2010-06-14 (月) 22:57:11)
- 3 (2010-06-15 (火) 13:26:11)
- 4 (2011-07-12 (火) 17:35:54)
- 5 (2011-10-18 (火) 19:01:43)
- 6 (2011-10-19 (水) 00:19:54)
- 7 (2012-05-15 (火) 12:49:23)
- 8 (2012-05-15 (火) 14:16:17)
- 9 (2012-09-19 (水) 18:18:48)
- 10 (2012-11-23 (金) 04:44:23)
- 11 (2012-12-30 (日) 09:29:21)
- 12 (2013-09-14 (土) 21:04:15)
- 13 (2013-10-29 (火) 19:26:30)
- 14 (2014-06-10 (火) 18:58:34)
- 15 (2014-11-01 (土) 00:46:09)
- 16 (2014-11-06 (木) 01:40:43)
- 17 (2014-11-13 (木) 19:52:53)
- 18 (2014-12-02 (火) 01:48:11)
- 19 (2015-04-01 (水) 20:11:20)
- 20 (2015-04-10 (金) 13:29:52)
- 21 (2016-06-01 (水) 18:42:41)
- 22 (2017-03-29 (水) 19:44:36)
- 23 (2017-04-04 (火) 14:17:08)
- 24 (2017-11-02 (木) 15:34:40)
- 25 (2018-02-17 (土) 20:19:27)
- 26 (2018-02-24 (土) 19:51:30)
- 27 (2020-02-14 (金) 16:20:33)
- 28 (2021-07-31 (土) 08:07:01)
- 29 (2021-11-17 (水) 04:19:27)
- 30 (2021-12-13 (月) 00:06:37)
- 31 (2022-08-20 (土) 22:15:25)
- 32 (2022-09-26 (月) 11:27:03)
- 33 (2023-02-25 (土) 21:27:51)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JFrameを半透明化
#navi(../)
RIGHT:Posted by [[terai]] at 2010-06-14
*JFrameを半透明化 [#ea286453]
JFrameを半透明にします。
-&jnlp;
-&jar;
-&zip;
#screenshot
**サンプルコード [#l5dd57cc]
#code{{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
//com.sun.awt.AWTUtilities.setWindowOpacity(frame, .5f);
com.sun.awt.AWTUtilities.setWindowOpaque(frame, false);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add(new JButton("JButton"));
p.setBackground(new Color(.5f,.8f,.5f,.5f));
frame.getContentPane().add(p);
frame.setSize(320, 240);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}}
**解説 [#v5c228ee]
com.sun.awt.AWTUtilities.setWindowOpacity(frame, .5f);を使って半透明化すると、フレームのタイトルバーや、子コンポーネントまで半透明化されるので、代わりに上記のサンプルでは以下のようにして半透明化を行っています。
-JFrame.setDefaultLookAndFeelDecorated(true);で、タイトルパーなどをJRootPaneに描画
-com.sun.awt.AWTUtilities.setWindowOpaque(frame, false);でJFrameを完全に透明化
-ContentPaneにsetBackground(new Color(.5f,.8f,.5f,.5f));で半透明の背景色を設定したパネルを追加
**参考リンク [#pc13cea7]
-[[江戸の文様(和風素材・デスクトップ壁紙)>http://www.viva-edo.com/komon/edokomon.html]]
-[[How to Create Translucent and Shaped Windows>http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/]]
**コメント [#d57b3c09]
- そんな簡単にできるんですね!昔画面キャプチャしたり色々苦労した結果断念しました; -- [[riki]] &new{2010-06-14 (月) 22:57:11};
#comment