Hello, I'm catching a component's (in this case a JFrame) move event, and am changing the component's location, which fires off another move event, and so on. Does someone know how to suppress the subsequent move events? Thanks!
Bryan Fagan
Greenhorn
Joined: Feb 26, 2001
Posts: 17
posted
0
Hi Ian: I believe what you are looking for is the SwingUtilities.invokeLater method. The method waits for all events to occur and then executes your code. This means your componentMoved method is only executed once. See code below. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; public class Test extends JFrame { public Test() { setSize(100,100); setVisible(true); addComponentListener(new ComponentListen()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(1); } }); } public static void main(String[] args) { Test tst = new Test(); } }