Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

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

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.

screen

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...