1 4 package com.tc.admin.common; 5 6 import java.awt.event.ActionEvent ; 7 import java.awt.event.ActionListener ; 8 import java.awt.event.ComponentAdapter ; 9 import java.awt.event.ComponentEvent ; 10 11 import javax.swing.Timer ; 12 13 import org.dijon.Frame; 14 15 public class XFrame extends Frame { 16 private Timer storeTimer; 17 18 public XFrame() { 19 super(); 20 21 storeTimer = new Timer (1000, new ActionListener () { 22 public void actionPerformed(ActionEvent e) { 23 storeBounds(); 24 } 25 }); 26 storeTimer.setRepeats(false); 27 28 addComponentListener(new ComponentListener()); 29 } 30 31 public void storeBounds() {} 32 33 class ComponentListener extends ComponentAdapter { 34 public void componentResized(ComponentEvent e) { 35 if(storeTimer.isRunning()) { 36 storeTimer.stop(); 37 } 38 storeTimer.start(); 39 } 40 public void componentMoved(ComponentEvent e) { 41 if(storeTimer.isRunning()) { 42 storeTimer.stop(); 43 } 44 storeTimer.start(); 45 } 46 } 47 } 48 | Popular Tags |