How to hide the Java SWT program icon in the Dock when the application is in the tray

家住魔仙堡 提交于 2019-12-17 20:18:49

问题


I know there are a lot of questions similar to mine, but I actually couldn't solve my problem even after reading all of them. I have a Java application that as soon as it starts it goes on tray. The problem is on Mac, because only there the icon is in the tray bar AND in the Dock. I want to get rid of the Dock icon.

I did already a number of trials: try to wrap my jar in a ".app" folder and writing an Info.plist file. I inserted the LSUIElement and set it to "1" or to "true". This hides the application Icon, but shows an ugly grey icon terminal-like that remains in the terminal.

Tell me even if you have any ideas or other ways to bypass this. thankyou.


回答1:


You may be using the wrong property name for what you want. Have a look here:

https://developer.apple.com/library/mac/#documentation/Java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html

The property you want to set is, I think:

"apple.awt.UIElement" (not "LSUIElement")

There are two ways you can do that. You can pass:

-Dapple.awt.UIElement="true"

as a VM argument, or you can set a property in the Info.plist as:

<key>Properties</key>
  <dict>
    <key>apple.awt.UIElement</key>
    <string>true</string>
  </dict>


来源:https://stackoverflow.com/questions/8246766/how-to-hide-the-java-swt-program-icon-in-the-dock-when-the-application-is-in-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!