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
You can register a HierarchyBoundsListener on your JFrame, or use a ComponentListener as suggested by others.
jf.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
@Override
public void ancestorMoved(HierarchyEvent e) {
updateText(jf, jl);
}
});
JFrame jf = new JFrame();
jf.addComponentListener(new ComponentListener() {...});
is what you are looking for, I think.
Using addComponentListener() with a ComponentAdapter:
jf.addComponentListener(new ComponentAdapter() {
public void componentMoved(ComponentEvent e) {
updateText(jf, jl);
}
});