Java在Linux上全屏 - 如何覆盖任务栏?
我在“openSUSE 11.4 (x86_64)”上以全屏模式运行 Java 应用程序时遇到问题。我正在使用 Java 1.6.0_26-b03。
我尝试运行全屏应用程序的两个示例:
- 来自 Oracle 站点的示例: 显示模式测试。
- JDarkRoom.jar(简单文本编辑器)从 Codealchemists 下载。
在这两种情况下,我的应用程序上都可见 Linux 任务栏。一定是与系统设置/配置有关吗?
I have a problem to run Java application in full screen mode on "openSUSE 11.4 (x86_64)". I am using Java 1.6.0_26-b03.
I have try to run two examples of full screen application:
- Example from Oracle site: Display Mode Test.
- JDarkRoom.jar (simple text editor) downloaded from Codealchemists.
In both cases I have a Linux Task bar visible over the application. It must be something with system settings/configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该能够使用
GraphicsDevice.setFullScreenWindow(窗口)
进入“真正的全屏”。然而,由于最流行的 Java 运行时中的错误,这可能不适用于运行 1.6 = Java 6 系列中某些“损坏”版本的系统。我还没有对此进行彻底测试,因此该补丁可能还没有传播到普通大众。https://bugs.java.com/bugdatabase/view_bug?bug_id=7057287
背景/理论
好的,这里的信息太多,但帮助却不够……这里有一些原因没正常工作……
失败:
基本上,窗口管理器暗示 Sun/Oracle(或 Red Hat,复制了Sun/Oracle,或可能是 IBM,因为他们可能也做了同样的事情,但我没有看到任何人抱怨他们)……
不过,我确实看到一些人来来回回地抱怨这是否是 K 桌面环境的窗口管理器(KWin)的一个错误(特别是) ,因为显然这个错误只出现在 K 中,不出现在 Gnome、XFCE 和朋友中。
解决方法
除了修补 Java 运行时(和/或客户的)之外,唯一真正的修复方法是使用特定于平台的 Java 库(也许使用反射来获取底层 AWT 对象...... eww ...)并自行设置正确的窗口提示。
是的,这太恶心了……
You should be able to go “really full screen” with
GraphicsDevice.setFullScreenWindow (window)
. However, due to bugs in the most popular Java runtimes, this may not work on systems running certain “broken” versions in the 1.6 = Java 6 series. I haven't tested this thoroughly, so it may be that the patch hasn't propagated out to the general populace, yet.https://bugs.java.com/bugdatabase/view_bug?bug_id=7057287
Background/Theory
OK, so here goes for too much information, and not enough help… Here's a bit of why this didn't work right…
And the Fail:
Basically, the window manager hints specification wasn't being followed correctly by Sun/Oracle (or Red Hat, who copied off Sun/Oracle, or probably IBM, because they probably did the same, but I don't see anybody complaining about them)…
Although, I do see some griping back and forth about whether it's a bug (specifically) with the K Desktop Environment's window manager (KWin), as apparently this bug only shows up in K, and not in Gnome, XFCE, and friends.
Work-Around
Aside from patching your Java runtimes (and/or your customers'), the only real fix would be to use the platform-specific Java libraries (perhaps grab the underlying AWT objects using reflection… eww…) and set the proper window hints, yourself.
Yes, that's gross…
只是对bgroenks方法的精确描述:
它可以在 Ubuntu 14.10 (Unity) 上与 java7 和 java8 正常工作。
但是:您必须设置
frame.setResizable(true);
,否则它将无法工作。请注意:全屏模式仅适用于 JFrame(不适用于 JDialog 或 JWindow)。
这里是一个示例代码:
它取代了
setVisible(true)
问候,Stéphane。
Just a precision on the method of bgroenks:
It's work fine with java7 and java8 on Ubuntu 14.10 (Unity).
BUT: You must set
frame.setResizable(true);
otherwise, it won't work.Be careful: the fullscreen mode only works with JFrame (no JDialog or JWindow).
Here a sample code:
It takes place of
setVisible(true)
Regards, Stéphane.
我意识到这个问题有点老了,但我偶然发现它寻找相同的答案。
经过大量实验,我想出了一个很好的解决方案:
焦点侦听器使用户可以通过 ALT-TAB 或 META-D 移出窗口,而不会立即强制重新聚焦。
这适用于我的带有 KDE 4 的 Linux Mint 15 系统。我还使用 NVIDIA X-Server。
希望这有帮助!让我知道它是否也适合你们!
I realize this question is a bit old, but I stumbled upon it looking for the same answer.
After a lot of experimenting, I came up with a good solution:
The focus listener is so the user can ALT-TAB or META-D out of the window without it immediately forcing re-focus.
This works on my Linux Mint 15 system with KDE 4. I am also using a NVIDIA X-Server.
Hope this helps! Let me know if it works for you guys too!
以上都不适合我,我使用的是 XUbuntu,但我只是尝试使用 JWindow 而不是 JFrame,它起作用了!这太令人沮丧了,希望它对你有用。哦,我应该提一下,我还没有看过 API,而且我真的不熟悉 JWindow 类,所以我不确定 JWindow 和 JFrame 之间到底有什么区别。祝你好运。
None of the above worked for me, I'm using XUbuntu, But I just tried using a JWindow instead of a JFrame and it worked! That was so frustrating, hopefully it works for you. Oh I should mention I haven't looked at the API yet and I'm really not familiar with the JWindow class so I'm not sure exactly what the differences are between a JWindow and a JFrame. Good luck.
我使用全屏模式使用 Oracle Java 版本 1.6.0_31 和 1.6.0_26
模式。我遇到了一些问题,在 Ubuntu 上,窗口没有显示在任务栏上方。不过我能够用这个小代码示例让它工作。
有效的技巧是首先使窗口可见,然后将窗口置于全屏模式。在显示之前设置全屏模式会导致任务栏位于窗口上方。
I've used Oracle Java editions 1.6.0_31 and 1.6.0_26 using full screen
mode. I experienced some of the troubles with the window not showing above the taskbar on Ubuntu. However I was able to make it work with this little code sample.
The trick that worked is making the window visible first, then placing the window in full screen mode. Setting full screen mode before it's shown resulted in the task bar above the window.