From 857bed00f6ed1dea8a629b7b7d0129b26d485094 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Sat, 4 Jan 2014 17:28:20 +0000 Subject: [PATCH] Set the dock icon on OS X. Not perfect as it still shows the standard Java logo for a second or two, but better than nothing git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5151 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/Viewport.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index a6ce3554..e7d76a54 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -27,6 +27,7 @@ import java.awt.Event; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.awt.Image; import java.awt.Window; import java.lang.reflect.*; import javax.swing.*; @@ -41,7 +42,23 @@ public class Viewport extends JFrame setTitle(name+" - TigerVNC"); setFocusable(false); setFocusTraversalKeysEnabled(false); - setIconImage(VncViewer.frameIcon); + 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 { + setIconImage(VncViewer.frameIcon); + } UIManager.getDefaults().put("ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{})); sp = new JScrollPane(); @@ -133,7 +150,6 @@ public class Viewport extends JFrame } catch (Exception e) { vlog.debug("Could not enable OS X 10.7+ full-screen mode: " + e.getMessage()); - } } -- 2.39.5