aspose file tools*
The moose likes Java in General and the fly likes Detecting JInternalFrame movement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Detecting JInternalFrame movement" Watch "Detecting JInternalFrame movement" New topic
Author

Detecting JInternalFrame movement

Michael Crutcher
Ranch Hand

Joined: Feb 18, 2002
Posts: 48
I would like to be able to detect a JInternalFrame's movement so that I can sync the movement of two frames. InternalFrameListner does not seem to be notified when an internalframe is moved to another place.
Right now I'm thinking that I'll need to detect a click and drag on the JInternalFrame, then ask it for its location, then set the location of the other frame.
Am I missing something? Is there a simpler way to do this?
Thanks,
Michael Crutcher
saager mhatre
Ranch Hand

Joined: Dec 20, 2000
Posts: 61
You could track movement on a javax.swing.JInternalFrame using java.awt.event.ComponentListener. Add your listener to the JInternalFrame's listener queue using JInternalFrame.addComponentListener(ComponentListener) and listen for the ComponentEvent from ComponentListener.componentMoved(ComponentEvent). Then use ComponentEvent.getSource() to retrieve a reference to the JInternalFrame that moved and check for its location.

A little example should get you on your way!

[ July 19, 2002: Message edited by: saager mhatre ]
Michael Crutcher
Ranch Hand

Joined: Feb 18, 2002
Posts: 48
Wow, thanks!
saager mhatre
Ranch Hand

Joined: Dec 20, 2000
Posts: 61
Always glad to be of help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detecting JInternalFrame movement