home *** CD-ROM | disk | FTP | other *** search
/ Laura Lemay's Web Workshop: ActiveX & VBScript / Laura_Lemays_Web_Workshop_ActiveX_and_VBScript_Version_1.0_1997.iso / source / chapter15 / mercutio.java < prev    next >
Text File  |  1996-09-26  |  1KB  |  41 lines

  1. import java.awt.*;
  2.  
  3. public class Mercutio extends java.applet.Applet {
  4.     Button b = new Button("Speak!");
  5.     TextField t = new TextField(45);
  6.     int phrase = 0;
  7.  
  8.     public void init() {
  9.         String bt = getParameter("ButtonTitle");
  10.         if (bt != null)
  11.               b.setLabel(bt);
  12.         add(b);
  13.         add(t);
  14.     }
  15.         
  16.     public boolean action(Event evt, Object obj) {
  17.         if (++phrase > 5) phrase = 0;
  18.         switch (phrase) {
  19.             case 0:
  20.                 t.setText("If love be rough with you, be rough with love.");
  21.         break;
  22.             case 1:
  23.                 t.setText("Dost thou make us minstrels?");
  24.         break;
  25.             case 2:
  26.                 t.setText("Speak but one rhyme, and I am satisfied.");
  27.         break;
  28.             case 3:
  29.                 t.setText("Any man that can write may answer a letter.");
  30.         break;
  31.             case 4:
  32.                 t.setText("Go, villain, fetch a surgeon.");
  33.         break;
  34.             default:
  35.                 t.setText("They have made worms' meat of me.");
  36.         }
  37.         repaint();
  38.         return false;
  39.     }
  40. }
  41.