View Javadoc
1 package com.bonevich.util.dependency; 2 3 import java.awt.EventQueue; 4 5 /*** 6 * Extends <code>Dependent</code> for use by Java AWT and Swing 7 * components. It places the call to <code>onGet()</code> 8 * on the AWT event queue. 9 */ 10 public final class VisualDependent extends Dependent 11 { 12 private boolean _running = true; 13 14 public VisualDependent(UpdateAction update) 15 { 16 super(update); 17 18 // Start update notification 19 fireUpdateEvent(); 20 } 21 22 public void cleanup() 23 { 24 // Do not post any more update events 25 _running = false; 26 super.cleanup(); 27 } 28 29 protected void invalidate() 30 { 31 super.invalidate(); 32 33 // While active, fire off update event 34 if (_running) 35 { 36 fireUpdateEvent(); 37 } 38 } 39 40 private void fireUpdateEvent() 41 { 42 //Post an event to bring the visual attribute back to a valid state 43 //System.err.println("posting an update event to the EventQueue"); 44 EventQueue.invokeLater( 45 new Runnable() 46 { 47 public void run() 48 { 49 onGet(); 50 } 51 } 52 ); 53 } 54 } /*** end class VisualDependent */

This page was automatically generated by Maven