Swing/DockingFrames のバックアップ差分(No.10)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/DockingFrames へ行く。
- 1 (2005-07-04 (月) 07:42:08)
- 2 (2005-10-07 (金) 14:42:05)
- 3 (2005-10-09 (日) 18:18:49)
- 4 (2006-02-27 (月) 15:48:53)
- 5 (2006-04-12 (水) 19:41:47)
- 6 (2006-09-12 (火) 16:01:14)
- 7 (2006-09-12 (火) 17:24:39)
- 8 (2007-03-06 (火) 03:35:34)
- 9 (2007-09-25 (火) 16:22:07)
- 10 (2013-02-20 (水) 15:29:39)
- 11 (2013-03-27 (水) 16:51:28)
- 12 (2013-08-29 (木) 01:14:06)
- 13 (2014-11-25 (火) 03:03:31)
- 14 (2015-01-13 (火) 11:25:48)
- 15 (2016-08-02 (火) 14:19:27)
- 16 (2017-09-30 (土) 23:29:45)
- 17 (2019-03-28 (木) 14:37:50)
- 18 (2021-01-06 (水) 20:06:57)
- 19 (2023-07-01 (土) 01:07:39)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JFrameの移動を同期 #navi(../) #tags() RIGHT:Posted by &author(aterai); at 2005-07-09 *JFrameの移動を同期 [#qa088c78] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2005-07-09~ 更新日:&lastmod; #contents **概要 [#r16f61f8] JFrameを2つ並べて作成し、その位置関係を保ったまま移動できるようにします。 #screenshot **サンプルコード [#f580c5f3] #code{{ private void positionFrames(ComponentEvent e) { if(e.getSource().equals(frame1)) { int x = frame1.getBounds().x; int y = frame1.getBounds().y + frame1.getBounds().height; frame2.removeComponentListener(this); frame2.setLocation(x, y); frame2.addComponentListener(this); }else{ int x = frame2.getBounds().x; int y = frame2.getBounds().y - frame1.getBounds().height; frame1.removeComponentListener(this); frame1.setLocation(x, y); frame1.addComponentListener(this); } } }} -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh4.ggpht.com/_9Z4BYR88imo/TQTLtEL3M0I/AAAAAAAAAYA/9HmyXI1Uw0M/s800/DockingFrames.png) **サンプルコード [#f580c5f3] #code(link){{ private void positionFrames(ComponentEvent e) { if(e.getSource().equals(frame1)) { int x = frame1.getBounds().x; int y = frame1.getBounds().y + frame1.getBounds().height; frame2.removeComponentListener(this); frame2.setLocation(x, y); frame2.addComponentListener(this); }else{ int x = frame2.getBounds().x; int y = frame2.getBounds().y - frame1.getBounds().height; frame1.removeComponentListener(this); frame1.setLocation(x, y); frame1.addComponentListener(this); } } }} **解説 [#ceedca5e] 上記のサンプルでは、JFrameを上下に並べて、それぞれにComponentListenerインタフェースを実装したリスナーを追加しています。片方のフレームが移動された時、残りのフレームの位置を指定する前に、一旦このリスナーを削除してやることで、処理がループしないようになっています。 **参考リンク [#q31d1b00] -[[how to dock two jdialogs?>http://forum.java.sun.com/thread.jspa?threadID=545918]] -[[how to catch drag event in the title bar of a jframe>http://forum.java.sun.com/thread.jspa?threadID=429463]] -[http://forums.sun.com/thread.jspa?threadID=545918 Swing (Archive) - how to dock two jdialogs?] -[http://forums.sun.com/thread.jspa?threadID=429463 Swing (Archive) - how to catch drag event in the title bar of a jframe] **コメント [#ic655f15] #comment