From 77453e6f87758d456d8e304dd927c9cff533af62 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Fri, 10 Jan 2014 04:05:32 +0000 Subject: [PATCH] Moved OS X setDockIconImage call into VncViewer.setLookAndFeel so that the dockImage gets set faster. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5153 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/Viewport.java | 17 +---------------- java/com/tigervnc/vncviewer/VncViewer.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index e7d76a54..8cb87b6f 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -42,23 +42,8 @@ public class Viewport extends JFrame setTitle(name+" - TigerVNC"); setFocusable(false); setFocusTraversalKeysEnabled(false); - if (VncViewer.os.startsWith("mac os x")) { - try { - Class appClass = Class.forName("com.apple.eawt.Application"); - Method getApplication = - appClass.getMethod("getApplication", (Class[])null); - Object app = getApplication.invoke(appClass); - Class paramTypes[] = new Class[1]; - paramTypes[0] = Image.class; - Method setDockIconImage = - appClass.getMethod("setDockIconImage", paramTypes); - setDockIconImage.invoke(app, VncViewer.logoImage); - } catch (Exception e) { - vlog.debug("Could not set OS X dock icon: " + e.getMessage()); - } - } else { + if (!VncViewer.os.startsWith("mac os x")) setIconImage(VncViewer.frameIcon); - } UIManager.getDefaults().put("ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{})); sp = new JScrollPane(); diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java index e63ec3b1..8d9b23a6 100644 --- a/java/com/tigervnc/vncviewer/VncViewer.java +++ b/java/com/tigervnc/vncviewer/VncViewer.java @@ -39,6 +39,7 @@ import java.io.InputStream; import java.io.IOException; import java.io.File; import java.lang.Character; +import java.lang.reflect.*; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.*; @@ -75,6 +76,17 @@ public class VncViewer extends javax.swing.JApplet public static void setLookAndFeel() { try { + if (os.startsWith("mac os x")) { + Class appClass = Class.forName("com.apple.eawt.Application"); + Method getApplication = + appClass.getMethod("getApplication", (Class[])null); + Object app = getApplication.invoke(appClass); + Class paramTypes[] = new Class[1]; + paramTypes[0] = Image.class; + Method setDockIconImage = + appClass.getMethod("setDockIconImage", paramTypes); + setDockIconImage.invoke(app, VncViewer.logoImage); + } // Use Nimbus LookAndFeel if it's available, otherwise fallback // to the native laf, or Metal if no native laf is available. String laf = System.getProperty("swing.defaultlaf"); -- 2.39.5