Here you can find the source of configureMacOSApplication(String appName, String dockImagePath)
Parameter | Description |
---|---|
appName | The name of the Application |
dockImagePath | The String path of the image to use as the dock icon |
public static void configureMacOSApplication(String appName, String dockImagePath)
//package com.java2s; import javax.swing.*; import java.awt.*; import java.lang.reflect.Method; import java.net.*; public class Main { /**//from w w w . j a v a 2s.c o m * Set a few common properties for the given application if we are running * under MacOS. Usage Example: * * <pre> * if (MacOSUtil.isMacOS()) { * MacOSUtil.configureMacOSApplication("JabaDex"); * } * </pre> * * @param appName - * the name of the Application. */ public static void configureMacOSApplication(String appName) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("apple.awt.showGrowBox", "true"); //System.setProperty("apple.awt.fileDialogForDirectories", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", appName); } /** * Set common properties and dock image for the given application is we are running * on Mac OS X * @param appName The name of the Application * @param dockImagePath The String path of the image to use as the dock icon */ public static void configureMacOSApplication(String appName, String dockImagePath) { configureMacOSApplication(appName); try { // Use reflection to invoke Apple's proprietary methods Class<?> clazz = Class.forName("com.apple.eawt.Application"); Method method = clazz.getMethod("getApplication", null); Object application = method.invoke(null, null); Method method2 = application.getClass().getMethod("setDockIconImage", Image.class); URL dockImageURL = "".getClass().getResource(dockImagePath); Image dockImage = new ImageIcon(dockImageURL).getImage(); method2.invoke(application, dockImage); } catch (Exception e) { // Do nothing } } }