Swing/LayeredPane のバックアップの現在との差分(No.21)
- category: swing folder: LayeredPane title: JInternalFrameを一番手前に表示 tags: [JLayeredPane, JInternalFrame, JDesktopPane] author: aterai pubdate: 2004-06-21T07:16:58+09:00 description: JLayeredPaneを使って、常に一番手前に表示されるJInternalFrameを作成します。 image:
概要
JLayeredPane
を使って、常に一番手前に表示されるJInternalFrame
を作成します。
Screenshot
Advertisement
サンプルコード
#spandel
JInternalFrame iframe = new JInternalFrame("AlwaysOnTop",
#spanend
true, //resizable
false, //closable
true, //maximizable
true); //iconifiable
#spanadd
JInternalFrame iframe = new JInternalFrame(
#spanend
"AlwaysOnTop", // title
true, // resizable
false, // closable
true, // maximizable
true); // iconifiable
iframe.setSize(180, 180);
desktop.add(iframe, Integer.valueOf(JLayeredPane.MODAL_LAYER + 1));
iframe.setVisible(true);
View in GitHub: Java, Kotlin解説
JDesktopPane
は、JLayeredPane
を継承しているので、JInternalFrame
を追加するレイヤーを指定することができます。
このサンプルでは、タイトルがAlwaysOnTop
のJInternalFrame
を、JLayeredPane.MODAL_LAYER
の一つ上に設定し、他のJInternalFrame
(ここでは後から追加するJInternalFrame
)より常に手前に表示されるように設定しています。
JDesktopPane
はJLayeredPane
を継承しているため、JInternalFrame
を追加するレイヤーを指定可能です。このサンプルでは、タイトルがAlwaysOnTop
のJInternalFrame
をJLayeredPane.MODAL_LAYER
の一つ上に設定し、他のJInternalFrame
(ここでは後から追加するJInternalFrame
)より常に手前に表示されるように設定しています。
参考リンク
- JLayeredPane (Java Platform SE 8)
- メモ: JInternalFrameは最初にアイコン化しておかないと位置が更新されない
- JInternalFrameは最初にアイコン化しておかないと位置が更新されない