Java tutorial
import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600, 400); frame.setVisible(true); Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { System.out.println(frame.getLocation()); }, 0, 1000, TimeUnit.MILLISECONDS); } }