tags:

views:

116

answers:

2

We have a program with multiple top-level swing windows (frames).

We are adding some "debug mode" where for each window of the original application there should be a specialized window that displays some information and offers some controls related to the original window. This is running in the same process as the original application so I would have access to the original window object.

Since this doubles the number of onscreen windows (and there are quite a few of them to begin with), I'm wondering if there is a convenient way to "attach" the new window to the old window so that if the new window is on the side of the old window they would move together and grow together vertically.

+2  A: 

I guess you could attach a ComponentAdapter to the target window and listen for window move events. Then adjust your debug window position accordingly.

Edit: I don't remember exactly but either Java 7 or Windows 7 has the support to snap windows together automagically.

kd304
+1  A: 

If you override the setBounds() method on the original window you can pick up when it is both moved and resized, then move your special windows to compensate.

Spyder