Java Swing Mac OSX 标题栏

发布于 2024-12-25 05:44:44 字数 329 浏览 1 评论 0原文

我正在 OSX 上开发 Java Swing 应用程序,我希望它看起来尽可能像 Mac。我已经实现了大部分想要的外观,但有一件事仍然让我困惑。

这是标题栏。许多本机 OSX 应用程序都有一个“高”标题栏,上面有“工具栏按钮”,右上角还有一个用于切换“工具栏按钮”显示/隐藏的小按钮(请参阅 FeedForAll 应用程序的图像,该应用程序是 Java 但使用 SWT) 。

FeedForAll 应用程序窗口顶部显示类似 Mac 的标题栏

有什么想法可以实现这一点吗?任何帮助或指示将不胜感激。

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 still eludes me.

It's the Title Bar. Many native OSX apps have a 'high' title bar with 'toolbar buttons' on it and a small button to toggle show/hide of the 'toolbar buttons' on the top right (see image of 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 much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不气馁 2025-01-01 05:44:44

在 Swing 中,实际上并未使用本机操作系统组件。 Mac 上默认的“Aqua”外观和感觉尝试尽可能匹配本机外观,但它实际上只是使用 Java2D 进行绘制。因此,例如,默认按钮的脉冲发光未实现。

您可以在窗口上设置一些客户端属性来影响其外观,但“标题工具栏”似乎不是一个选项:

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

一种选择是切换到使用Quaqua 的外观和感觉。我自己没有使用过它,但据说它比 Aqua 更忠实于 Mac 的外观。它有一个属性,您可以设置它以获得所需的工具栏外观:

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

In Swing, native OS components are not actually used. The default "Aqua" look and feel on Mac tries to match the native look as well as possible, but it is really just painting things with Java2D. So, for example, the pulsing glow of the default button is not implemented.

There are some client properties you can set on the window to affect its appearance, but the "title toolbar" does not seem to be an option:

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

One option would be to switch to using the Quaqua look and feel. I haven't used it myself, but supposedly it is even more faithful to the Mac look than Aqua is. It has a property you can set to get the toolbar appearance you want:

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

花心好男孩 2025-01-01 05:44:44

You might look into the Unified Tool Bar available in Mac Widgets for Java.

面犯桃花 2025-01-01 05:44:44

抱歉,我认为您无法使用 Swing 获得工具栏控制按钮。没有 appl-esqe 系统属性可以为您绘制它。尝试“apple.awt.brushMetalLook”属性,但据我记得它只有统一的工具栏和标题栏。
SWT 似乎是您唯一的选择。

另外,我认为您不应该担心这个 UI 元素。自 10.7 (Lion) 以来,此按钮已从所有 OS X 用户界面元素中删除

使用 Lion,大多数应用程序顶部都有全屏图标正确的。
当使用 Swing 进行 OS X 编程时,我认为您应该在追求的某个时刻画一条线,让它看起来绝对是原生的。

除此之外,我认为 Mozilla 客户端是用 Objective C/C++ 和一些 Java(可能是)针对 Mac 开发的。

Sorry, but I do not think you can get the toolbar control button using Swing. There are no appl-esqe system properties that would draw it for you. Try "apple.awt.brushMetalLook" property, but as far as I remember it just had the unified toolbar and titlebar.
SWT seems like your only choice.

Also, I do not think you should worry about this UI element.This button is removed from all OS X user interface elements since 10.7 (Lion)

With Lion, most of the applications have the fullscreen icon on top right.
When using Swing for OS X programming I think you should draw a line at some point in your quest to get it looking absolutely native.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文