tags:

views:

422

answers:

2

How can I have one window move with another? i.e., I'd like a JDialog to follow a JFrame when the JFrame is being dragged. If the JFrame moves by (+5, +20), the JDialog needs to move the same.

I've tried using ComponentListeners, but I only receive drag events in chunks which causes the JDialog window to be jumpy while dragging the main JFrame. I've tried using MouseListeners, but I can't figure out how to detect events on the actual frame of the JFrame.

+1  A: 

Try using the ComponentListener.componentMoved event instead of monitoring drag events on the JFrame.

Software Monkey
A: 

AFAIK here is no move multiple windows in AWT. To get the moves to be called at a similar time, I guess you want the JFrame decorations to be PL&F rendered. Put in a PL&F-specific hack to do the moves yourself, moving both windows at almost the same time. You may still have a problem with exposing bits of windows only to cover them up causing some performance degradation.

Tom Hawtin - tackline