Home Segments Top Top Previous Next

894: Mainline

Once you understand how to place Runnable instances on the display work queue, you are ready to define MarqueThread properly.

import javax.swing.*;
public class MarqueeThread extends Thread {
 private Marquee marquee;
 public MarqueeThread (Marquee c) {
   marquee = c;
 }
 public void run () {
  while (true) {
   // Good programming practice; do it this way!             
   ChangeHandler changeHandler = new ChangeHandler(marquee); 
   SwingUtilities.invokeLater(changeHandler);                
   try{sleep(200);}                              
   catch (InterruptedException e) {}      
  } 
 } 
}