diff -urN vnc_javasrc.orig/AboutBox.java vnc_javasrc/AboutBox.java --- vnc_javasrc.orig/AboutBox.java Wed Dec 31 16:00:00 1969 +++ vnc_javasrc/AboutBox.java Sat Oct 5 15:06:10 2002 @@ -0,0 +1,45 @@ +// +// File: AboutBox.java +// + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.net.URL; + +public class AboutBox extends JFrame + implements ActionListener +{ + protected JButton okButton; + protected JLabel aboutText; + + public AboutBox() { + super(); + this.getContentPane().setLayout(new BorderLayout(10, 0)); + this.setFont(new Font ("SansSerif", Font.BOLD, 14)); + + URL url = AboutBox.class.getResource("vnc.gif"); + Image img=Toolkit.getDefaultToolkit().getImage(url); + ImageIcon icon = new ImageIcon(img); + aboutText = new JLabel ("
Java VNC viewer
" + + "from tightvnc.com
with minor WorkSpot mods
", + icon, SwingConstants.CENTER); + aboutText.setVerticalTextPosition(JLabel.BOTTOM); + aboutText.setHorizontalTextPosition(JLabel.CENTER); + JPanel textPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0)); + textPanel.add(aboutText); + this.getContentPane().add (textPanel, BorderLayout.NORTH); + + okButton = new JButton("OK"); + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15)); + buttonPanel.add (okButton); + okButton.addActionListener(this); + this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); + this.pack(); + } + + public void actionPerformed(ActionEvent newEvent) { + setVisible(false); + } + +} diff -urN vnc_javasrc.orig/VncViewer.java vnc_javasrc/VncViewer.java --- vnc_javasrc.orig/VncViewer.java Sat Oct 5 15:04:37 2002 +++ vnc_javasrc/VncViewer.java Sat Oct 5 15:04:12 2002 @@ -29,12 +29,17 @@ import java.awt.event.*; import java.io.*; import java.net.*; +import java.util.*; +import javax.swing.*; +import com.apple.mrj.*; public class VncViewer extends java.applet.Applet - implements java.lang.Runnable, WindowListener { + implements java.lang.Runnable, WindowListener, MRJOpenDocumentHandler, MRJOpenApplicationHandler, + MRJAboutHandler, MRJQuitHandler { boolean inAnApplet = true; boolean inSeparateFrame = false; + protected AboutBox aboutBox = null; // // main() is called when run as a java program from the command line. @@ -42,13 +47,10 @@ // public static void main(String[] argv) { - VncViewer v = new VncViewer(); - v.mainArgs = argv; - v.inAnApplet = false; - v.inSeparateFrame = true; - - v.init(); - v.start(); + VncViewer v = new VncViewer(); + v.runAsApp(argv); + // v.init(); + // v.start(); } String[] mainArgs; @@ -87,6 +89,29 @@ int deferUpdateRequests; + public void runAsApp (String[] argv) { + aboutBox = new AboutBox(); + mainArgs = argv; + inAnApplet = false; + inSeparateFrame = true; + Toolkit.getDefaultToolkit(); + MRJApplicationUtils.registerAboutHandler(this); + MRJApplicationUtils.registerQuitHandler(this); + MRJApplicationUtils.registerOpenDocumentHandler(this); + MRJApplicationUtils.registerOpenApplicationHandler(this); + } + + public void handleAbout() { + aboutBox.setResizable(false); + aboutBox.setVisible(true); + aboutBox.show(); + } + + public void handleQuit() { + System.exit(0); + } + + // // init() // @@ -769,4 +794,48 @@ public void windowClosed(WindowEvent evt) {} public void windowIconified(WindowEvent evt) {} public void windowDeiconified(WindowEvent evt) {} + + public void handleOpenFile(File file) { + try { + String[] params = { "HOST", "www.foo.com", "PORT", "5001", + "ENCPASSWORD", "8888888888888888" }; + BufferedReader in = new BufferedReader(new FileReader(file)); + String line; + while ((line = in.readLine()) != null) { + if (line.startsWith("host=")) { + params[1] = line.substring(5); + } else if (line.startsWith("port=")) { + params[3] = line.substring(5); + } else if (line.startsWith("password=")) { + params[5] = line.substring(9); + } + } + mainArgs = params; + } catch (Exception ex) { + System.out.println("Error reading VNC config file: " + ex.getMessage()); + System.exit(1); + } + + init(); + start(); + } + + public void handleOpenApplication() { + String where = JOptionPane.showInputDialog(null, + "Host Name : Display Number", + "New VNC Connection", + JOptionPane.PLAIN_MESSAGE); + if (where == null) { + System.exit(1); + } + StringTokenizer st = new StringTokenizer(where, " :"); + String[] params = { "HOST", "www.foo.com", "PORT", "5001" }; + params[1] = st.nextToken().trim(); + params[3] = st.nextToken().trim(); + + mainArgs = params; + init(); + start(); + } + }