TITLE:JInternalFrameを固定
#navi(../)
*JInternalFrameを固定 [#o5f11a62]
>編集者:[[Terai Atsuhiro>terai]]~
作成日:2005-10-10~
更新日:&lastmod;

#contents

**概要 [#lf0dad2e]
JInternalFrameをマウスなどで移動できないように固定します。

#screenshot

**サンプルコード [#a83e5c01]
#code{{
 BasicInternalFrameUI ui = (BasicInternalFrameUI)immovableFrame.getUI();
 Component north = ui.getNorthPane();
 MouseMotionListener[] actions
   = (MouseMotionListener[])north.getListeners(MouseMotionListener.class);
 for(int i=0;i<actions.length;i++) {
   north.removeMouseMotionListener(actions[i]);
 }
}}
-&jnlp;
-&jar;
-&zip;

**解説 [#k07f6217]
JInternalFrameのMouseMotionListenerをすべて削除することで、マウスによる移動を不可能にしています。

以下のようにしてタイトルバーを削除しても、移動できないフレームを作成することができます。
#code{{
 ui.setNorthPane(null);
 internalframe.setBorder(BorderFactory.createEmptyBorder());
 internalframe.setSize(200,50);
 internalframe.add(new JLabel("移動できないフレーム", SwingConstants.CENTER));
 internalframe.setLocation(10,10);
 internalframe.pack();
}}

#screenshot(,screenshot2.png)

**参考リンク [#t17ee3f9]
-[[Lock JInternalPane>http://forum.java.sun.com/thread.jspa?threadID=609043]]

**コメント [#rd25830b]
#comment