diff options
author | Brian Hinz <bphinz@users.sourceforge.net> | 2013-03-01 01:10:07 +0000 |
---|---|---|
committer | Brian Hinz <bphinz@users.sourceforge.net> | 2013-03-01 01:10:07 +0000 |
commit | 12da5fab8d4d927a6659d02dd95bffd15d961df8 (patch) | |
tree | 4d65f84466205bd670766f909bb914642c3494c6 /java/com/tigervnc/vncviewer/VncViewer.java | |
parent | 8b61dd59f11bc5ad79a35d05977ddb0f73c0f392 (diff) | |
download | tigervnc-12da5fab8d4d927a6659d02dd95bffd15d961df8.tar.gz tigervnc-12da5fab8d4d927a6659d02dd95bffd15d961df8.zip |
Replace multiple instantiations of code to retrieve resources (icons, timestamp) from jar file with statics.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5054 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com/tigervnc/vncviewer/VncViewer.java')
-rw-r--r-- | java/com/tigervnc/vncviewer/VncViewer.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java index ebd90b47..31043d1e 100644 --- a/java/com/tigervnc/vncviewer/VncViewer.java +++ b/java/com/tigervnc/vncviewer/VncViewer.java @@ -60,6 +60,14 @@ public class VncViewer extends java.applet.Applet implements Runnable public static String build = null; public static String buildDate = null; public static String buildTime = null; + static ImageIcon frameIconSrc = + new ImageIcon(VncViewer.class.getResource("tigervnc.ico")); + public static final Image frameIcon = frameIconSrc.getImage(); + public static final ImageIcon logoIcon = + new ImageIcon(VncViewer.class.getResource("tigervnc.png")); + public static final Image logoImage = logoIcon.getImage(); + public static final InputStream timestamp = + VncViewer.class.getResourceAsStream("timestamp"); public static void setLookAndFeel() { try { @@ -282,17 +290,12 @@ public class VncViewer extends java.applet.Applet implements Runnable vlog.debug("init called"); setLookAndFeel(); setBackground(Color.white); - ClassLoader cl = this.getClass().getClassLoader(); - ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.png")); - logo = icon.getImage(); } private void getTimestamp() { if (version == null || build == null) { - ClassLoader cl = this.getClass().getClassLoader(); - InputStream stream = cl.getResourceAsStream("com/tigervnc/vncviewer/timestamp"); try { - Manifest manifest = new Manifest(stream); + Manifest manifest = new Manifest(timestamp); Attributes attributes = manifest.getMainAttributes(); version = attributes.getValue("Version"); build = attributes.getValue("Build"); @@ -333,8 +336,8 @@ public class VncViewer extends java.applet.Applet implements Runnable } public void paint(Graphics g) { - g.drawImage(logo, 0, 0, this); - int h = logo.getHeight(this)+20; + g.drawImage(logoImage, 0, 0, this); + int h = logoImage.getHeight(this)+20; g.drawString(String.format(aboutText, version, build, buildDate, buildTime), 0, h); } @@ -378,10 +381,7 @@ public class VncViewer extends java.applet.Applet implements Runnable JOptionPane op = new JOptionPane(e.getMessage(), JOptionPane.WARNING_MESSAGE); JDialog dlg = op.createDialog("TigerVNC Viewer"); - ClassLoader cl = this.getClass().getClassLoader(); - ImageIcon icon = - new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.ico")); - dlg.setIconImage(icon.getImage()); + dlg.setIconImage(frameIcon); dlg.setVisible(true); } else { if (!cc.shuttingDown) @@ -557,7 +557,6 @@ public class VncViewer extends java.applet.Applet implements Runnable Thread thread; Socket sock; boolean applet; - Image logo; static int nViewers; static LogWriter vlog = new LogWriter("main"); } |