TITLE:JInternalFrameを一番手前に表示

JInternalFrameを一番手前に表示

Posted by terai at 2004-06-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: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTO8wLpaZI/AAAAAAAAAdM/mML3cGeQwrg/s800/LayeredPane.png

概要

JLayeredPaneを使って、常に一番手前に表示されるJInternalFrameを作成します。

概要

JLayeredPaneを使って、常に一番手前に表示されるJInternalFrameを作成します。
  • &jnlp;
  • &jar;
  • &zip;

#screenshot

サンプルコード

#spanend
#spandel
JInternalFrame iframe = new JInternalFrame("AlwaysOnTop",
#spanend
  true,  //resizable
  false, //closable
  true,  //maximizable
  true); //iconifiable
#spanadd
* サンプルコード [#sourcecode]
#spanend
#spanadd
#code(link){{
#spanend
#spanadd
JInternalFrame iframe = new JInternalFrame(
#spanend
  "AlwaysOnTop", // title
  true,  // resizable
  false, // closable
  true,  // maximizable
  true); // iconifiable
iframe.setSize(180, 180);
#spandel
desktop.add(iframe, new Integer(JLayeredPane.MODAL_LAYER+1));
#spanend
#spanadd
desktop.add(iframe, Integer.valueOf(JLayeredPane.MODAL_LAYER + 1));
#spanend
iframe.setVisible(true);

解説

JDesktopPane は、JLayeredPane を継承しているので、JInternalFrame を追加するレイヤーを指定することができます。 このサンプルでは、タイトルが"AlwaysOnTop"のJInternalFrameを、JLayeredPane.MODAL_LAYERの一つ上に設定し、他のJInternalFrame(ここでは後から追加するJInternalFrame)より常に手前に表示されるように設定しています。

解説

JDesktopPaneJLayeredPaneを継承しているため、JInternalFrameを追加するレイヤーを指定可能です。このサンプルでは、タイトルがAlwaysOnTopJInternalFrameJLayeredPane.MODAL_LAYERの一つ上に設定し、他のJInternalFrame(ここでは後から追加するJInternalFrame)より常に手前に表示されるように設定しています。

参考リンク

参考リンク

コメント

  • 1.5でJFrameなどは、frame.setAlwaysOnTop(true)が使えるようになっています。 -- terai
  • ありがとうございます。現在GUIの作成をしていて、目下この情報を探していました。ありがとうございました -- G

コメント