Home Segments Top Top Previous Next

892: Mainline

To put work on the display-operations queue, you define a class that implements the Runnable interface, with a run method that calls the decrementPosition method of the Marquee class. If you call that class ChangeHandler, then you call decrementPosition by adding a ChangeHandler instance to the display work queue, as described in Segment 893

import java.util.*; 
import java.awt.event.*; 
import javax.swing.*; 
public class ChangeHandler implements Runnable { 
 private Marquee marquee; 
 public ChangeHandler (Marquee c) { 
  marquee = c; 
 } 
 public void run() { 
  marquee.decrementPosition(); 
 } 
}