Java Swing Mac OSX Header Bar

I am working on a Java Swing application on OSX and I want it to appear as Mac-Like as possible. I have achieved most of the desired look, but one thing is still eluding me.

This is the title bar. Many native OSX applications have a “tall” title with “toolbar buttons” and a small button for switching / closing “toolbar buttons” in the upper right corner (see Image of the FeedForAll application, which is Java but uses SWT).

Top of FeedForAll application window showing Mac-Like title bar

Any ideas how this can be achieved? Any help or pointers would be greatly appreciated.

+4
source share
3 answers

In Swing, the original OS components are not actually used. By default, “Aqua” looks and feels on a Mac to match its appearance as soon as possible, but it's really just drawing things with Java2D. So, for example, the pulsating glow of a button is not implemented by default.

There are some client properties that you can set in the window to affect its appearance, but the "title bar" does not look like this:

http://developer.apple.com/library/mac/#technotes/tn2007/tn2196.html#//apple_ref/doc/uid/DTS10004439

One option is to switch to using Quaqua. I have not used it myself, but perhaps it is more faithful to the Mac than Aqua. It has a property that you can configure to get the appearance of the toolbar:

http://www.randelshofer.ch/quaqua/guide/client_properties.html#JToolBar

+2
source

You can take a look at the Unified toolbar available on Mac Widgets for Java .

+2
source

Sorry, but I don’t think you can get the toolbar control button using Swing. There are no appl-esqe features that would draw it for you. Try the apple.awt.brushMetalLook property, but as far as I remember, it had a single toolbar and title. SWT seems to be your only choice.

Also, I don't think you should worry about this user interface element. This button has been removed from all OS X user interface elements since 10.7 (Lion)

With Lion, most applications have a full-screen icon in the upper right corner. When using Swing to program on OS X, I think you should draw a line at some point in your quest so that it looks completely native.

To add to this, I think Mozilla clients are developed in Objective C / C ++ and some Java (maybe) for Mac.

+1
source

Source: https://habr.com/ru/post/1389508/


All Articles