Movement « JFrame « Java Swing Q&A





1. Java: how to register a listener that listen to a JFrame movement    stackoverflow.com

How can you track the movement of a JFrame itself? I'd like to register a listener that would be called back every single time JFrame.getLocation() is going to return a new ...

2. Detect frame movement    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MoveFrame extends JFrame { public MoveFrame() { super( "Move Me" ); setSize( 500, 500 ); addComponentListener( new ComponentAdapter() { public void componentMoved( ComponentEvent ce ) { Component c = ce.getComponent(); System.out.println( c.getLocation() ); } }); } public static void main(String[] args) { new MoveFrame().setVisible( true ); } }

3. Detecting user movement of a JFrame    java-forums.org

The JavaDoc for a ComponentEvent states that the COMPONENT_MOVED event is triggered only if the component's position has changed. I interpret this to mean the location of the component (coordinates of upper left hand corner). So if the component is resized, but the location does not change, then the COMPONENT_MOVED event should not occur. But if I create a JFrame, add ...