home *** CD-ROM | disk | FTP | other *** search
/ Internet Gallery / INTERGAL.bin / intergal / prgs / idv21 / data.z / CrazyText.java < prev    next >
Text File  |  1995-10-08  |  2KB  |  73 lines

  1. // CrazyText.java
  2. // Version 2.0
  3. // Works with JDK 1.0 beta2.
  4. // Patrick Taylor (taylor@us.net)
  5. // Based on Daniel Wyszynski's NervousText applet from the JDK 1.0 beta1.
  6. // See accompanying HTML documentation for detailed information.
  7. // Requires CrazyLabel class.
  8.  
  9. import java.awt.Font;
  10. import java.awt.Event;
  11. import java.awt.Dimension;
  12. import java.awt.BorderLayout;
  13.  
  14. public class CrazyText extends java.applet.Applet {
  15. //JAVADRAW Wizard.Cut.Start
  16. String AText = "SFS Software";
  17. Font AFont = new Font ("TimesRoman", Font.PLAIN, 10);
  18. int ADelay = 10;
  19. int Delta = 10;
  20. //JAVADRAW Wizard.Cut.End
  21.  
  22. protected CrazyLabel label;
  23.  
  24.    protected static String[][] paramInfo = {
  25.    
  26.       {"hgap",        "int",        "horizontal spacing between chars"},
  27.       {"hspace",    "int",        "extra spacing on left and right"},
  28.       {"vspace",    "int",        "extra spacing on top and bottom"},
  29.       {"clear",     "boolean",     "clear background on update"},
  30.       {"cycle",     "string",     "color changes: whole|char|none"},
  31.       
  32.  };
  33.  
  34.    public String[][] getParameterInfo() {
  35.       return paramInfo;
  36.    }
  37.  
  38.    protected String getParam(String name, String defaultVal) {
  39.       String val = getParameter(name);
  40.       return (val == null) ? defaultVal : val;
  41.    }
  42.  
  43.    public void init() {
  44.       
  45.       // create and configure label
  46.       label = new CrazyLabel(AText);
  47.       label.setDelay(ADelay);
  48.       label.setDelta(ADelta);
  49.       label.setHgap(0);
  50.       label.setHspace(0);
  51.       label.setVspace(0);
  52.       label.setClear(getParam("clear","false").equals("true"));
  53.       label.setCycle(getParam("cycle","whole"));
  54.       label.setFont(AFont);
  55.  
  56.       // add label to applet container
  57.       setLayout(new BorderLayout());
  58.       add("Center", label);
  59.  
  60.       // this doesn't work now, but it might someday
  61.       resize(minimumSize());
  62.    }
  63.  
  64.    public void start() {
  65.       label.start();
  66.    }
  67.  
  68.    public void stop() {
  69.       label.stop();
  70.    }
  71.   
  72.   }
  73.