Author: bdonlan
Date: 2005-01-08 21:04:54 -0500 (Sat, 08 Jan 2005)
New Revision: 557

Added:
   trunk/misc/javer/src/javer/JaverApplet.java
Modified:
   /
Log:
 [EMAIL PROTECTED]:  bdonlan | 2005-01-09T02:03:39.298177Z
 Somehow this wasn't committed before. So, adding the applet source.



Property changes on: 
___________________________________________________________________
Name: svk:merge
   - 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local:11293
   + 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local:11295

Added: trunk/misc/javer/src/javer/JaverApplet.java
===================================================================
--- trunk/misc/javer/src/javer/JaverApplet.java 2005-01-09 01:49:40 UTC (rev 
556)
+++ trunk/misc/javer/src/javer/JaverApplet.java 2005-01-09 02:04:54 UTC (rev 
557)
@@ -0,0 +1,153 @@
+/*
+ * JaverApplet.java
+ *
+ * Created on January 6, 2005, 11:22 PM
+ */
+
+package javer;
+
+/**
+ *
+ * @author bdonlan
+ */
+public class JaverApplet extends javax.swing.JApplet {
+    
+    Panel panel = null;
+    String[] autojoin = null;
+    
+    /** Creates a new instance of JaverApplet */
+    public JaverApplet() {
+        super();
+    }
+
+    /**
+     * Called by the browser or applet viewer to inform
+     * this applet that it should stop its execution. It is called when
+     * the Web page that contains this applet has been replaced by
+     * another page, and also just before the applet is to be destroyed.
+     * <p>
+     * A subclass of <code>Applet</code> should override this method if
+     * it has any operation that it wants to perform each time the Web
+     * page containing it is no longer visible. For example, an applet
+     * with animation might want to use the <code>start</code> method to
+     * resume animation, and the <code>stop</code> method to suspend the
+     * animation.
+     * <p>
+     * The implementation of this method provided by the
+     * <code>Applet</code> class does nothing.
+     * 
+     * @see     java.applet.Applet#destroy()
+     * @see     java.applet.Applet#init()
+     */
+    public void stop() {
+        /* appletviewer calls this when we switch desktops.
+         * appletviewer sucks.
+         */
+        panel.do_disconnect();
+        super.stop();
+    }
+
+    /**
+     * Called by the browser or applet viewer to inform
+     * this applet that it has been loaded into the system. It is always
+     * called before the first time that the <code>start</code> method is
+     * called.
+     * <p>
+     * A subclass of <code>Applet</code> should override this method if
+     * it has initialization to perform. For example, an applet with
+     * threads would use the <code>init</code> method to create the
+     * threads and the <code>destroy</code> method to kill them.
+     * <p>
+     * The implementation of this method provided by the
+     * <code>Applet</code> class does nothing.
+     * 
+     * @see     java.applet.Applet#destroy()
+     * @see     java.applet.Applet#start()
+     * @see     java.applet.Applet#stop()
+     */
+    public void init() {
+        String host;
+        int port;
+        String autojoin_str;
+        super.init();
+        System.out.println("init");
+        host = this.getParameter("hostname");
+        port = Integer.decode(this.getParameter("port")).intValue();
+        autojoin_str = this.getParameter("autojoin");
+        System.out.println("autojoin = " + autojoin_str);
+        if (autojoin_str != null) {
+            autojoin = autojoin_str.split("[, ]+");
+            System.out.println("count = " + autojoin.length);
+        } else {
+            autojoin = null;
+        }
+        panel = new Panel(this, host, port);
+        getContentPane().setLayout(new java.awt.GridLayout(1,0));
+        getContentPane().add(panel);
+    }
+
+    /**
+     * Called by the browser or applet viewer to inform
+     * this applet that it is being reclaimed and that it should destroy
+     * any resources that it has allocated. The <code>stop</code> method
+     * will always be called before <code>destroy</code>.
+     * <p>
+     * A subclass of <code>Applet</code> should override this method if
+     * it has any operation that it wants to perform before it is
+     * destroyed. For example, an applet with threads would use the
+     * <code>init</code> method to create the threads and the
+     * <code>destroy</code> method to kill them.
+     * <p>
+     * The implementation of this method provided by the
+     * <code>Applet</code> class does nothing.
+     * 
+     * @see     java.applet.Applet#init()
+     * @see     java.applet.Applet#start()
+     * @see     java.applet.Applet#stop()
+     */
+    public void destroy() {
+        panel.do_disconnect();
+        super.destroy();
+    }
+
+    protected final class Panel extends JaverUIPanel {
+        JaverApplet applet;
+        public Panel(
+                JaverApplet a,
+                String hostname,
+                int port) {
+            super(hostname, port);
+            System.out.println("subclass panel init");
+            this.applet = a;
+        }
+
+        public boolean processLine(String query) {
+
+            boolean retValue;
+
+            retValue = super.processLine(query);
+            return retValue;
+        }
+
+        protected Client spawnClient() {
+            return new SubClient();
+        }
+
+        protected final class SubClient extends javer.JaverUIPanel.Client {
+            protected void eventIdentAccepted() throws java.io.IOException {
+                super.eventIdentAccepted();
+                System.out.println("check autojoin");
+                if (autojoin != null) {
+                    int i;
+                    for (i = 0; i < autojoin.length; i++) {
+                        putServer("Auto-joining " + autojoin[i]);
+                        cli.join(autojoin[i]);
+                    }
+                }
+            }
+        }
+
+    }
+
+    
+}


Property changes on: trunk/misc/javer/src/javer/JaverApplet.java
___________________________________________________________________
Name: svn:eol-style
   + native


Reply via email to