开发者

How can I change the default icon of a java application on a mac using netbeans?

I have a java application that will need to be deployed on both windows and mac. On windows, I've configured the system to use a .png file as the icon for the application, but the mac requires an icns file. I've created the icns file, but I can't figure out how to set that as the icon to use for the application (in t开发者_StackOverflow中文版he dock, expose, etc). I'd also need the PC side to ignore that icon assignment.

How can I do this in netbeans?

EDIT: I added have this line in my build.xml file, as per this link:

<property name="app.icon.icns" value="${dist.dir}/Mac64/yellowMac.icns"/>

and the yellowMac.icns file is in the same directory as the .jar file, still no joy.


Call this inside the constructor

//For Microsoft Windows
setIconImage(new ImageIcon("Football.png").getImage());
//For Mac OS X
Application.getApplication().setDockIconImage(new ImageIcon("Football.png").getImage());


Note that if you deploy your application with Java WebStart then the snippet in the JNLP file allows for creating a proper Mac app including the icon.


For Netbeans 8.0.2 you can set the .icns file for the Mac OS X bundle when Netbeans builds the native DMG package.

Make sure your .icns file has all of the required icons for a Mac OS X application bundle.

Then...

  • Right click on the project and select Properties

  • Under Build -> Deployment

  • select Enable Native Packaging

  • Click on the Icons and Splash Image: Native -> Edit... button
  • Enter a (relative) file location to your .icns file in the Native Package Icon: textfield.
  • Hit all of the required OKs.

  • Right click on you project

  • select Package as -> DMG Image

Wait a while until it says BUILD SUCCESSFUL. The .dmg file will be in the dist/bundles directory.


I was able to add a line to the file nbproject/project.properties:

app.icon.icns=yellowMac.icns

When building the Mac OSX Installer, this icns file was correctly copied over to the .app.


in case anyone faces this problem try this

<property name="deploy.icon.native" value="p.icns"/>

where p.icns is inside the project base directory

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜