minimal changes to get the code to start up outside an applet environment
authorAdam Megacz <adam@megacz.com>
Sun, 10 Jan 2010 02:07:19 +0000 (18:07 -0800)
committerAdam Megacz <adam@megacz.com>
Sun, 10 Jan 2010 02:07:19 +0000 (18:07 -0800)
src/mcsClient/McsClient.java
src/mcsClient/Row.java

index b3c690d..76250ae 100644 (file)
@@ -6,8 +6,7 @@ package mcsClient;
 
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
 import java.awt.*;
-import java.io.IOException;
-import java.io.PrintStream;
+import java.io.*;
 import java.net.URL;
 import java.util.LinkedList;
 import java.util.StringTokenizer;
@@ -18,7 +17,44 @@ import javax.swing.*;
 //            LiveVideoPanel, McsKeyAdapter, McsMouseAdapter, McsMouseMotionAdapter, 
 //            DatagramReader, McsToolBar, MessageReader, KeepAlive
 
-public class McsClient extends JApplet {
+public class McsClient extends JPanel/*Applet*/ {
+
+    public Container getContentPane() { return this; }
+
+    private String  _host;
+    private String  _userid;
+    private String  _ac;
+    private boolean _enc;
+    public McsClient(String host, String userid, String ac, boolean enc) {
+        this();
+        this._host = host;
+        this._userid = userid;
+        this._ac = ac;
+        this._enc = enc;
+    }
+    public String getParameter(String key) {
+        if (key.equals("bluescreen")) return "false";
+        if (key.equals("ac"))         return _ac;
+        if (key.equals("userid"))     return _userid;
+        if (key.equals("host"))       return _host;
+        if (key.equals("enc"))        return _enc ? "on" : "off";
+        throw new RuntimeException("unknown key \""+key+"\"");
+    }
+
+    static void go(String host, String user, String password) throws Exception {
+        JFrame jf = new JFrame();
+        McsClient mcs = new McsClient(host, user, password, false);
+        jf.add(mcs);
+        jf.setSize(1200,1000);
+        jf.pack();
+        jf.show();
+        jf.setSize(1200,1000);
+        mcs.init();
+        jf.repaint(1000);
+    }
+
+
+    // Changes appear above this line //////////////////////////////////////////////////////////////////////////////
 
     private static final int FIXED_SIZE = 1;
     private static final int FULL_SCREEN = 2;
@@ -49,7 +85,7 @@ public class McsClient extends JApplet {
     private boolean blueScreenDump;
     private boolean encryptVideo;
 
-    public McsClient() {
+    private McsClient() {
         mcsTargetSize = new McsTargetSize(1024, 768);
         datagramList = new LinkedList();
         mcsVersion = new McsVersion();
@@ -67,8 +103,10 @@ public class McsClient extends JApplet {
         System.out.println("MCS v.3.6 initialized");
         isStandalone = false;
         String s = getParameter("host");
+        /*
         if (s == null)
             s = getCodeBase().getHost();
+        */
         String s1 = s;
         String s2 = getParameter("bluescreen");
         if (s2 != null && s2.equalsIgnoreCase("true"))
index ef8c78f..683bccf 100644 (file)
@@ -112,6 +112,7 @@ final class Row extends JPanel
     }
 
     public boolean isValid() {
+        if (clear==null) return false;
         return clear.isEnabled();
     }