JInternalFrameを固定
Total: 4748
, Today: 2
, Yesterday: 2
Posted by aterai at
Last-modified:
概要
JInternalFrame
をマウスなどで移動できないように固定します。
サンプルコード
BasicInternalFrameUI ui = (BasicInternalFrameUI) immovableFrame.getUI();
Component titleBar = ui.getNorthPane();
for (MouseMotionListener l: titleBar.getListeners(MouseMotionListener.class)) {
titleBar.removeMouseMotionListener(l);
}
view all解説
JInternalFrame
のMouseMotionListener
をすべて削除して、マウスによる移動を不可能に設定しています。
- 以下のようにタイトルバー自体を削除して移動できないフレームを作成する方法もある
ui.setNorthPane(null); internalframe.setBorder(BorderFactory.createEmptyBorder()); internalframe.setSize(200, 50); internalframe.add(new JLabel("移動不可フレーム", SwingConstants.CENTER)); internalframe.setLocation(10, 10); internalframe.pack();