我如何获得真正可用的分辨率 [英] How do I get the real usable resolution

查看:42
本文介绍了我如何获得真正可用的分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Toolkit.getDefaultToolkit().getScreenSize()

我知道屏幕尺寸.

但通常这不是我自己程序的可用大小,因为在 Mac 上有一个顶部菜单栏和底部图标栏.Windows 也有一个图标栏.那么我如何获得真正的可用空间?

But usually this isn't the available size I have for my own program, because on the mac there is a menubar on top and on the bottom an iconbar. Windows also has an iconbar. So how do I get the real available space?

推荐答案

来自 Java 论坛:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = ge.getMaximumWindowBounds();

现在您有了不受平台依赖的桌面装饰的限制.我身边没有 Mac,所以我只验证它可以在 WinXP/JDK6 上运行.

Now you have the bounds sans platform-dependent desktop decorations. I don't have a Mac around so I only verified that it works on WinXP/JDK6.

请注意,如果您自动隐藏任务栏,则边界不包括任务栏,这是正确的.

Note that if you auto-hide taskbar, the bounds do NOT include taskbar, which is correct.

这篇关于我如何获得真正可用的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆