src/demo/share/applets/NervousText/NervousText.java

Print this page




  55  */
  56 @SuppressWarnings("serial")
  57 public class NervousText extends Applet implements Runnable, MouseListener {
  58 
  59     String banner;              // The text to be displayed
  60     char bannerChars[];         // The same text as an array of characters
  61     char attributes[];          // Character attributes ('^' for superscript)
  62     Thread runner = null;       // The thread that is displaying the text
  63     boolean threadSuspended;    // True when thread suspended (via mouse click)
  64     static final int REGULAR_WD = 15;
  65     static final int REGULAR_HT = 36;
  66     static final int SMALL_WD = 12;
  67     static final int SMALL_HT = 24;
  68     Font regularFont = new Font("Serif", Font.BOLD, REGULAR_HT);
  69     Font smallFont = new Font("Serif", Font.BOLD, SMALL_HT);
  70 
  71     @Override
  72     public void init() {
  73         banner = getParameter("text");
  74         if (banner == null) {
  75             banner = "HotJava";
  76         }

  77 
  78         int bannerLength = banner.length();
  79         StringBuilder bc = new StringBuilder(bannerLength);
  80         StringBuilder attrs = new StringBuilder(bannerLength);
  81         int wd = 0;
  82         for (int i = 0; i < bannerLength; i++) {
  83             char c = banner.charAt(i);
  84             char a = 0;
  85             if (c == '^') {
  86                 i++;
  87                 if (i < bannerLength) {
  88                     c = banner.charAt(i);
  89                     a = '^';
  90                     wd += SMALL_WD - REGULAR_WD;
  91                 } else {
  92                     break;
  93                 }
  94             }
  95             bc.append(c);
  96             attrs.append(a);




  55  */
  56 @SuppressWarnings("serial")
  57 public class NervousText extends Applet implements Runnable, MouseListener {
  58 
  59     String banner;              // The text to be displayed
  60     char bannerChars[];         // The same text as an array of characters
  61     char attributes[];          // Character attributes ('^' for superscript)
  62     Thread runner = null;       // The thread that is displaying the text
  63     boolean threadSuspended;    // True when thread suspended (via mouse click)
  64     static final int REGULAR_WD = 15;
  65     static final int REGULAR_HT = 36;
  66     static final int SMALL_WD = 12;
  67     static final int SMALL_HT = 24;
  68     Font regularFont = new Font("Serif", Font.BOLD, REGULAR_HT);
  69     Font smallFont = new Font("Serif", Font.BOLD, SMALL_HT);
  70 
  71     @Override
  72     public void init() {
  73         banner = getParameter("text");
  74         if (banner == null) {
  75             banner = "Java Development Kit ";
  76         }
  77         banner += System.getProperty("java.version", "");
  78 
  79         int bannerLength = banner.length();
  80         StringBuilder bc = new StringBuilder(bannerLength);
  81         StringBuilder attrs = new StringBuilder(bannerLength);
  82         int wd = 0;
  83         for (int i = 0; i < bannerLength; i++) {
  84             char c = banner.charAt(i);
  85             char a = 0;
  86             if (c == '^') {
  87                 i++;
  88                 if (i < bannerLength) {
  89                     c = banner.charAt(i);
  90                     a = '^';
  91                     wd += SMALL_WD - REGULAR_WD;
  92                 } else {
  93                     break;
  94                 }
  95             }
  96             bc.append(c);
  97             attrs.append(a);