Hello all,

I've got three JDialogs that I would like to "tie" to a JFrame. By "tie"
I mean that if someone moves the JFrame, it also moves the three
JDialogs by the same amount.

Someone earlier suggested that I use ComponentListener. I did this, and
it works, except that now whenever I move the main frame, it produces
this weird jittery epileptic seizure effect. The frame and the three
dialogs literally jump around like they're on crack. Here's how I handle
the movement:

  public void componentMoved(ComponentEvent e) {
    Rectangle newBounds = getBounds();
    int xdiff = newBounds.x - lastPos.x;
    int ydiff = newBounds.y - lastPos.y;

    // notify the dialogs               
    moveWindow.mainWindowMoved(xdiff, ydiff);
    branchWindow.mainWindowMoved(xdiff, ydiff);
    commentWindow.mainWindowMoved(xdiff, ydiff);

    // save off for next move   
    lastPos = newBounds;
  }

// This method is in each of the JDialogs....
  public void mainWindowMoved(int xDiff, int yDiff) {
    Rectangle ourSize = getBounds();
    ourSize.x += xDiff;
    ourSize.y += yDiff;
    setBounds(ourSize);
  }

The only reason for this that I can think of is a kind of recusrive
effect. By moving the dialogs, this causes another Component Moved event
to be fired in the Dialog's parent (the main frame). But this should
cause the entire process to go forever...

The project is available at http://chessaid.sourceforge.net if you want
to take a look at the exact effect. The lines in question are currently
commented out, so you'll have to go to
net.sourceforge.chessaid.gui.dialogs.CAMainFrame and uncomment it.

It's possible that this is a KDE effect and will not appear on other
platforms. If you can't reproduce it, let me know...

Any thoughts would be appreciated... thanks!


_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to