JInternalFrameを固定
Total: 6022
, Today: 1
, Yesterday: 1
Posted by aterai at
Last-modified:
Summary
JInternalFrame
をマウスなどで移動できないように固定します。
Screenshot

Advertisement
Source Code Examples
BasicInternalFrameUI ui = (BasicInternalFrameUI) immovableFrame.getUI();
Component titleBar = ui.getNorthPane();
for (MouseMotionListener l: titleBar.getListeners(MouseMotionListener.class)) {
titleBar.removeMouseMotionListener(l);
}
View in GitHub: Java, KotlinExplanation
JInternalFrame
のMouseMotionListener
をすべて削除して、マウスによる移動を不可能に設定しています。
- 以下のようにタイトルバー自体を削除して移動できないフレームを作成する方法もある
ui.setNorthPane(null); internalframe.setBorder(BorderFactory.createEmptyBorder()); internalframe.setSize(200, 50); internalframe.add(new JLabel("Non-movable frame", SwingConstants.CENTER)); internalframe.setLocation(10, 10); internalframe.pack();