使用 Substance LAF,Java 窗口无法在没有任务栏的屏幕上正确最大化

发布于 2024-10-23 21:42:56 字数 581 浏览 1 评论 0原文

我刚刚注意到,当我在第二个屏幕(没有任务栏)上最大化一个框架时,它最终会达到大约与任务栏存在时预期的边界。

我刚刚注意到这一点已切换到 Windows 7。以前在 Vista 中,我有一个实用程序可以将任务栏添加到两个屏幕,因此如果情况并非如此,这也可能是一个问题。我很确定这在我尝试过的几个窗口管理器的 Linux 中不是一个问题...

如果我使用默认的 LAF 运行我的程序,那么就会表现出正确的行为(使用完整的水平空间)屏幕)。我认为 StackOverflow 并不是提交 Substance 错误报告的最佳地点,但如果有人可以提出补救措施,或者确认它确实是一个错误并帮助确定它发生的情况,我们将不胜感激。

编辑:我刚刚对源代码进行了一些挖掘,发现了一些对 issue 213;这正是我现在遇到的缺陷,据称该缺陷在当时(早在 2007 年)就已修复,并且据报告在 XP 和 Windows 中可以正常工作。具有现代建筑的 Vista (4.1)。我可能会在某个时候尝试调试相关的代码;看起来相当容易管理。

/风滚草

I've just noticed that when I maximise a frame on my second screen - which has no taskbar - then it ends up with approximately the bounds one would expect if the taskbar was there.

I've just noticed this having switched to Windows 7. Previously in Vista, I had a utility to add a taskbar to both screens, so this may have been an issue there as well if that were not the case. I'm pretty sure this hasn't been an issue in Linux with a couple of window managers that I've tried...

If I run my program with the default LAF, then the proper behaviour is exhibited (using the full horizontal space of the screen). I suppose StackOverflow isn't really the best place to file a Substance bug report, but if anyone can suggest a remedy, or confirm that it is indeed a bug and help to identify the circumstances under which it occurs it would be much appreciated.

edit: I've just been digging through the source code a bit and found some references to issue 213; precisely the defect I'm now experiencing, which was supposedly fixed at the time (back in 2007) and reported to be working correctly in XP & Vista with a contemporary build (4.1). I might try to debug the relevant bits of code at some point; looks fairly manageable.

/tumbleweed

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

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

发布评论

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

评论(1

一江春梦 2024-10-30 21:42:56

我想说,如果它只发生在 LaF 物质上,那么它听起来绝对是一个你应该报告的错误……但我在发布之前刚刚看到了你的编辑。祝你好运,四年后说服他们修复它!

与此同时,您可以尝试的唯一真正的解决方法是获取当前显示的插图并以这种方式设置大小。下面是一些代码,用于计算每台显示器上的分辨率、边界和可用空间:

 public static void main(String... args) throws Exception {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gds = ge.getScreenDevices();
        for (GraphicsDevice gd : gds) {
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            System.out.println("Bounds = " + gc.getBounds());
            System.out.println("Insets = " + Toolkit.getDefaultToolkit().getScreenInsets(gc));
        }
    }

在像我这样的双屏 Windows 设置上,这显示了以下内容:

Bounds = java.awt.Rectangle[x=0,y=0,width=1280,height=1024] 
Insets = java.awt.Insets[top=0,left=0,bottom=30,right=0] 
Bounds = java.awt.Rectangle[x=1280,y=0,width=1280,height=1024] 
Insets = java.awt.Insets[top=0,left=0,bottom=0,right=0]

注意显示器底部的 30 像素插图1.

现在您需要做的就是弄清楚您的应用程序正在哪个屏幕上运行。如果您的应用程序窗口是 JFrameWindow 的任何其他子类,您可以使用 Window.getGraphicsConfiguration() 获取活动屏幕的图形配置代码>.

我希望这会有所帮助(也许它会帮助那些致力于解决 Substance bug 的人!)

I was going to say, if it's only occurring with the Substance LaF, then it definitely sounds like a bug that you should report... but I just saw your edit before posting. Good luck with persuading them to fix it after 4 years!

In the meantime, the only real workaround you could try is getting the insets of the current display and setting the size that way. Here's some code which works out the resolution, bounds and how much usable space is available on each of your monitors:

 public static void main(String... args) throws Exception {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gds = ge.getScreenDevices();
        for (GraphicsDevice gd : gds) {
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            System.out.println("Bounds = " + gc.getBounds());
            System.out.println("Insets = " + Toolkit.getDefaultToolkit().getScreenInsets(gc));
        }
    }

On a dual-screen Windows setup like I have, this shows the following:

Bounds = java.awt.Rectangle[x=0,y=0,width=1280,height=1024] 
Insets = java.awt.Insets[top=0,left=0,bottom=30,right=0] 
Bounds = java.awt.Rectangle[x=1280,y=0,width=1280,height=1024] 
Insets = java.awt.Insets[top=0,left=0,bottom=0,right=0]

Notice the 30-pixel insets at the bottom of monitor 1.

Now all you need to do is work out what screen your application is running on. You can use Window.getGraphicsConfiguration() this to get the graphics configuration for the active screen if your application window is a JFrame or any other subclass of Window.

I hope that helps (and perhaps it will help the people working on the Substance bug!)

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