home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Cdrom / Pavilions / BrainOpera / online / net-music / WebWatcher / webwatch.java < prev   
Encoding:
Java Source  |  2017-09-21  |  2.2 KB  |  101 lines

  1. import java.util.StringTokenizer;
  2. import java.net.*;
  3. import java.io.*;
  4. import java.applet.*;
  5. import java.applet.Applet;
  6. import java.awt.*;
  7.  
  8. public class WebWatch extends Applet implements Runnable, WebStarHandler
  9.  
  10. {
  11.     int myStarID;
  12.     String comment ="";
  13.     Thread kicker=null;
  14.     StarClient sc;
  15.     TextField port;
  16.     TextField message;
  17.  
  18.  
  19.     public void init()
  20.     {
  21.         Panel p= new Panel();
  22.         sc = new StarClient(this);
  23.         port = new TextField("port",5);
  24.         message = new TextField("Test Messages",30);
  25.         p.setLayout(new GridLayout(2, 3));
  26.         p.add(new Label("port"));
  27.         p.add(port);
  28.         p.add(new Button("Connect New Port"));
  29.         p.add(new Label("Test Message"));
  30.         p.add(message);
  31.         p.add(new Button("Send Message"));
  32.         add("Center",p);
  33.  
  34.  
  35.     }
  36.  
  37.     public void start()
  38.     {
  39.         if (kicker == null)
  40.         {
  41.  
  42.             kicker = new Thread(this);
  43.             kicker.start();
  44.  
  45.         }
  46.     }
  47.  
  48.     public void stop()
  49.     {
  50.         if (kicker != null)
  51.         {
  52.             kicker.stop();
  53.             kicker=null;
  54.         }
  55.         if (sc !=null) sc.stop();
  56.     }
  57.  
  58.     public void run()
  59.     {
  60.         Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
  61.         while (kicker !=null)
  62.         {
  63.             repaint();
  64.             try {Thread.sleep(100);} catch (InterruptedException e) {}
  65.         }
  66.     }
  67.  
  68.  
  69.     public void WS_up(String msg, Object who)
  70.     {
  71.         myStarID = sc.getStarID();
  72.         showStatus(msg);
  73.     }
  74.  
  75.     public void WS_down(String msg, Object who)
  76.     {
  77.         showStatus(msg);
  78.     }
  79.     public void WS_debugLog(String msg, Object who)
  80.     {
  81.         showStatus(msg);
  82.     }
  83.  
  84.     public void WS_newMsg(String msg, Object who)
  85.     {
  86.         showStatus(msg);
  87.     }
  88.  
  89.     public boolean action(Event evt, Object arg)
  90.     {
  91.             if (arg.equals("Connect New Port")) {
  92.                 if (sc !=null) sc.stop();
  93.                     sc.start(getDocumentBase().getHost(), Integer.valueOf(port.getText()).intValue());};
  94.                 if (arg.equals("Send Message")) sc.send(message.getText());
  95.                 return true;
  96.  
  97.  
  98.     }
  99.  
  100.  
  101. }