home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 2.2 KB | 101 lines |
- import java.util.StringTokenizer;
- import java.net.*;
- import java.io.*;
- import java.applet.*;
- import java.applet.Applet;
- import java.awt.*;
-
- public class WebWatch extends Applet implements Runnable, WebStarHandler
-
- {
- int myStarID;
- String comment ="";
- Thread kicker=null;
- StarClient sc;
- TextField port;
- TextField message;
-
-
- public void init()
- {
- Panel p= new Panel();
- sc = new StarClient(this);
- port = new TextField("port",5);
- message = new TextField("Test Messages",30);
- p.setLayout(new GridLayout(2, 3));
- p.add(new Label("port"));
- p.add(port);
- p.add(new Button("Connect New Port"));
- p.add(new Label("Test Message"));
- p.add(message);
- p.add(new Button("Send Message"));
- add("Center",p);
-
-
- }
-
- public void start()
- {
- if (kicker == null)
- {
-
- kicker = new Thread(this);
- kicker.start();
-
- }
- }
-
- public void stop()
- {
- if (kicker != null)
- {
- kicker.stop();
- kicker=null;
- }
- if (sc !=null) sc.stop();
- }
-
- public void run()
- {
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
- while (kicker !=null)
- {
- repaint();
- try {Thread.sleep(100);} catch (InterruptedException e) {}
- }
- }
-
-
- public void WS_up(String msg, Object who)
- {
- myStarID = sc.getStarID();
- showStatus(msg);
- }
-
- public void WS_down(String msg, Object who)
- {
- showStatus(msg);
- }
- public void WS_debugLog(String msg, Object who)
- {
- showStatus(msg);
- }
-
- public void WS_newMsg(String msg, Object who)
- {
- showStatus(msg);
- }
-
- public boolean action(Event evt, Object arg)
- {
- if (arg.equals("Connect New Port")) {
- if (sc !=null) sc.stop();
- sc.start(getDocumentBase().getHost(), Integer.valueOf(port.getText()).intValue());};
- if (arg.equals("Send Message")) sc.send(message.getText());
- return true;
-
-
- }
-
-
- }