From a69f60031e4d1b122359f3830a4a54ecee03f562 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sat, 9 Jan 2010 18:07:19 -0800 Subject: [PATCH] minimal changes to get the code to start up outside an applet environment --- src/mcsClient/McsClient.java | 46 ++++++++++++++++++++++++++++++++++++++---- src/mcsClient/Row.java | 1 + 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/mcsClient/McsClient.java b/src/mcsClient/McsClient.java index b3c690d..76250ae 100644 --- a/src/mcsClient/McsClient.java +++ b/src/mcsClient/McsClient.java @@ -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")) diff --git a/src/mcsClient/Row.java b/src/mcsClient/Row.java index ef8c78f..683bccf 100644 --- a/src/mcsClient/Row.java +++ b/src/mcsClient/Row.java @@ -112,6 +112,7 @@ final class Row extends JPanel } public boolean isValid() { + if (clear==null) return false; return clear.isEnabled(); } -- 1.7.10.4