OSX Lion 上 Java 应用程序的全屏功能
如何在 Java 应用程序中(本地)实现 OSX Lion 的全屏功能?
目前给出的答案包含了一种实现全屏功能的好方法。我读到 Eclipse 可能能够使用 Lion 的“本机”全屏功能。这就是我要问的。
How can I (natively) implement the fullscreen feature of OSX Lion in a Java application?
The current answers given incorporate a good method for achieving a sort-of-fullscreen feature. I've read that Eclipse may be able to use the "native" fullscreen feature of Lion. That's what I'm asking about.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我在 Apple 的 Java 发行说明中发现了这一点:
Mac OS X 10.7 Lion 全屏支持
Lion 上的 Java 应用程序现在可以选择每个窗口的全屏窗口功能。开发人员可以使用 com.apple.eawt.FullScreenUtilities 类将窗口标记为能够全屏,并且 com.apple.eawt.Application.requestToggleFullScreen(Window)方法以编程方式请求窗口进入和退出全屏模式。此 API 在 Mac OS X 10.6 Snow Leopard 上不执行任何操作。
更明确地说,尝试尽早从 JFrame 的构造函数中调用它...
I found this on Apple's Java release notes:
Mac OS X 10.7 Lion Fullscreen Support
Java applications on Lion can now opt into the Fullscreen window feature per-window. Developers can use the com.apple.eawt.FullScreenUtilities class to mark windows as able to be full screened, and the com.apple.eawt.Application.requestToggleFullScreen(Window) method to programmatically request the window enter and exit full screen mode. This API does nothing on Mac OS X 10.6 Snow Leopard.
More explicitly, try calling this early on from the constructor of your
JFrame
s...我不了解本机,但 Java 确实支持全屏应用程序,而不需要本机代码:
http://saipullabhotla.blogspot.com/2012/05/enabling-full-screen-mode-for-java.html
问题是苹果在他们的 JDK 中使用 Lion 实现了这一点。
I don't know about natively, but Java does support fullscreen applications without needing native code:
http://saipullabhotla.blogspot.com/2012/05/enabling-full-screen-mode-for-java.html
The question is has Apple implemented that with Lion in their JDK.
对于那些不介意快速而肮脏的解决方案的人:
从 Frame 构造函数调用
getRootPane().putClientProperty("apple.awt.fullscreenable", Boolean.valueOf(true))
。这就是setWindocCanFullScreen
的作用。For those of you who do not mind a quick and dirty solution:
Call
getRootPane().putClientProperty("apple.awt.fullscreenable", Boolean.valueOf(true))
from the Frame constructor. This is whatsetWindocCanFullScreen
does.您想要做的事情可以通过 com.apple.eawt 库来完成。此外,如果您还在 Windows、Linux 等其他操作系统上部署应用程序,为了避免通过反射编写代码,您应该在应用程序中使用和分发嵌入的 AppleJavaExtensions.jar 来自 Apple。
这是使框架可在全屏中展开的方法:
这是切换全屏的方法:
其中参数 window 是您尝试使其具有全屏功能的应用程序的 JFrame。
要查看示例应用程序,请查看 RationalPlan 项目。
What you are trying to do can be done through the com.apple.eawt library. Additionally in order to avoid writing code through reflection if you also deploy your application on other OSes like Windows, Linux etc. you should use and distribute embeded within your application the AppleJavaExtensions.jar from Apple.
This is the method to make a frame expandable in full screen:
And this is the method to toggle full screen:
where the parameter window is the JFrame of your application that you are trying to make full screen capable.
To see an example application have a look at RationalPlan Project.
请向 Apple 提交错误报告。他们在 OS X 上维护 Java,并且它应该符合他们发布的标准。
Please file a bug report with Apple. They maintain Java on OS X and it should conform to their published standards.
Java 允许您使用全屏模式,这与 Lion 无关。 (来自 chubbard)
如果你想用 Java 编写原生 Cocoa 应用程序,你需要使用 JavaBridge。但是,JavaBridge 已被弃用。
我的建议是:如果您想编写本机 OSX Cocoa 应用程序,请使用 Objective C 或 Macruby 进行。 MacRuby 目前正在接受 Apple 的资助(Sansonetti 是 Apple 的全职员工),并且可能会与 Cocoa 一起拥有未来。 Java 没有。
Java allows you full screen mode, that has nothing to do with Lion. (via chubbard)
If you want to write native Cocoa applications with Java, you need to use JavaBridge. However, JavaBridge is deprecated.
My recommendation is: If you want to write native OSX Cocoa applications, do it in Objective C or Macruby. MacRuby is currently receiving funding from Apple (Sansonetti is a full-time Apple employee) and might just have a future with Cocoa. Java doesn't.