Linux 上的全屏 Java - 如何覆盖任务栏?

标签 java swing fullscreen taskbar suse

我在“openSUSE 11.4 (x86_64)”上以全屏模式运行 Java 应用程序时遇到问题。我正在使用 Java 1.6.0_26-b03。

我尝试运行两个全屏应用程序示例:

  1. 来自 Oracle 站点的示例:Display Mode Test .
  2. Codealchemists 下载的 JDarkRoom.jar(简单文本编辑器) .

在这两种情况下,我都可以在应用程序上方看到一个 Linux 任务栏。一定是系统设置/配置的东西?

最佳答案

应该可以使用 GraphicsDevice.setFullScreenWindow (window) 进入“真正的全屏”。然而,由于最流行的 Java 运行时中的错误,这可能不适用于运行 1.6 = Java 6 系列中某些“损坏”版本的系统。我还没有对此进行彻底的测试,所以补丁可能还没有传播到普通民众。

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7057287

背景/理论

好吧,信息太多,帮助不够……这里有一些为什么这不起作用……

There is no Linux Desktop

Linux-based operating systems on PC-type machines, as well as other Unices (with a partial exception for MacOSX), normally use the X Window System (aka X11). Under X, you have an X Server (usually, something kinda like a “video driver”) and clients that connect to it, more often than not, from the same machine (loopback).

The layout and placement of windows is controlled by a special client program, called the Window Manager. It's responsible for decorating the windows (e.g. drawing title bars or resize handles) and positioning them.

Your program would be an X client. It can request — but not demand — placement on the screen at a certain position, or a certain size. Various Window Managers are more (or less) prone to giving you what you want.

Except, most desktops play nicely (sometimes)

Now, by far, most Linux desktops use the Gnome Desktop, with a strong second place for the K Desktop, and a few others are in fairly wide use. What's “nice” is that both of these desktop environments (as well as some others, like XFCE for low-end PC's) conform to the FreeDesktop.org Window Manager Hints standards.

(Super-over-simplification:) Typically, there will be Panels on one or more edges of the screen. Usually, there's just one, across the top, but there are many variations. These Panel areas are not considered “part of the screen,” so the Window Manager tells your application, “no, that's outside of the area in which you're allowed to play; this screen is not 1920×1080, it's only 1890×1080.” Of course, that could be totally different arrangement than what you'd anticipated when you wrote your app, and you might be on my netbook with a physical screen of 800×480 pretending to be only 780×480.

For 99% of apps, that's great. Windows don't get in the way of the Panels, so you can always reach the Panel for critical controls, like hitting Mute or switching to another program or something.

These “hints” allow you to request that your top-level windows get treated specially. For example, you can request that you get no title bar — or a reduced, “palette” type title bar; you can request to be skipped on the window list or task bar or activities overview or whatever other interface might be used to show the active windows; or, you can request to go really full-screen, and push everything else out of the way, even panels.

The spec is here: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html

和失败:

基本上,窗口管理器提示规范没有被 Sun/Oracle(或抄袭 Sun/Oracle 的 Red Hat,或者可能是 IBM,因为他们可能也这样做了,但我没有看到任何人)正确遵循提示他们)...

尽管如此,我确实看到一些人反复提示它是否(特别是)K 桌面环境的窗口管理器 (KWin) 的错误,因为显然这个错误只出现在 K 中,并且在 Gnome、XFCE 和 friend 中。

解决方法

除了修补您的 Java 运行时(和/或您的客户的)之外,唯一真正的解决方法是使用特定于平台的 Java 库(也许使用反射获取底层 AWT 对象……呃……)并设置适当的窗口提示,你自己。

是的,那太恶心了……

关于Linux 上的全屏 Java - 如何覆盖任务栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8837719/

相关文章:

java - 对于 JTable 来说,哪种编辑和删除行方法更好?

java - 获取 JTextComponent 的 HTMLDocument 中的当前偏移量

css完美全屏图片背景

java - Docker - 无法在 java 的卷之间移动文件

java - Java 的 PriorityQueue 是不稳定的还是非确定性的,或者两者兼而有之?

java - 用 drawString 绘制心形符号

javascript - 在 Safari 上退出全屏切换空间时 RequestAnimationFrame 不工作

在 IE9 和 Firefox 中使用全屏模式的 HTML5 视频

java - spring boot data jpa连接不上mysql数据库

Java Rest Api 返回 404