Swing/InternalFrameTitleBar のバックアップソース(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/InternalFrameTitleBar へ行く。
- 1 (2009-08-31 (月) 15:27:18)
- 2 (2009-08-31 (月) 17:21:54)
- 3 (2009-11-12 (木) 19:53:12)
- 4 (2009-11-13 (金) 14:56:10)
- 5 (2010-01-01 (金) 01:10:51)
- 6 (2010-01-18 (月) 11:35:05)
- 7 (2010-06-10 (木) 15:07:18)
- 8 (2010-08-02 (月) 02:19:26)
- 9 (2010-08-02 (月) 15:19:36)
- 10 (2011-04-21 (木) 16:01:06)
- 11 (2013-01-06 (日) 21:40:38)
- 12 (2013-06-15 (土) 17:45:00)
- 13 (2013-06-17 (月) 02:29:21)
- 14 (2013-07-26 (金) 01:34:07)
- 15 (2014-12-01 (月) 15:12:30)
- 16 (2015-01-28 (水) 15:04:43)
- 17 (2015-04-01 (水) 20:09:38)
- 18 (2015-04-03 (金) 16:07:54)
- 19 (2017-02-24 (金) 19:03:18)
- 20 (2018-01-03 (水) 19:55:34)
- 21 (2018-02-24 (土) 19:51:30)
- 22 (2019-12-25 (水) 19:45:24)
- 23 (2021-06-27 (日) 01:46:45)
TITLE:JInternalFrameをJFrameとして表示する #navi(../) RIGHT:Posted by [[terai]] at 2009-08-31 *JInternalFrameをJFrameとして表示する [#tf5e5ced] JFrameのタイトルバーなどを非表示にして、変わりにJInternalFrameのタイトルバーを表示します。 -&jnlp; -&jar; -&zip; #screenshot **サンプルコード [#k636189e] #code{{ final JInternalFrame internal = new JInternalFrame("@title@"); BasicInternalFrameUI ui = (BasicInternalFrameUI)internal.getUI(); Component title = ui.getNorthPane(); for(MouseMotionListener l:title.getListeners(MouseMotionListener.class)) { title.removeMouseMotionListener(l); } DragWindowListener dwl = new DragWindowListener(); title.addMouseListener(dwl); title.addMouseMotionListener(dwl); JPanel p = new JPanel(new BorderLayout()); p.add(new JScrollPane(new JTree())); p.add(new JButton(new AbstractAction("close") { public void actionPerformed(ActionEvent e) { SwingUtilities.windowForComponent((Component)e.getSource()).dispose(); } }), BorderLayout.SOUTH); internal.getContentPane().add(p); internal.setVisible(true); EventQueue.invokeLater(new Runnable() { public void run() { try{ internal.setSelected(true); }catch(java.beans.PropertyVetoException ex) { ex.printStackTrace(); } } }); }} **解説 [#d219693c] 上記のサンプルでは、JInternalFrameのタイトルバーを使用することで、閉じるボタンのないフレームを作成しています。 -JFrame#setUndecorated(true) で、JFrameのタイトルバーなどを非表示 -BasicInternalFrameUI#getNorthPane()でJInternalFrameのタイトルバーを取得 --元のMouseMotionListenerを削除 --JInternalFrameをドラッグすると親のJFrameが移動するMouseMotionListenerを追加 -制限 --最大化、最小化、リサイズなどには未対応 ---Alt+Spaceで最大化、最小化できるが、下のサイズに戻せなくなる場合がある --角の透明化には未対応 //**参考リンク **コメント [#b720b8d7] #comment