开发者

Java - Screen Size on a Mac

I have a Java application, and in order to find the size of the screen to use, I do the following, for example:

Toolkit.getDefaultToolkit().getScreenSize().width;
Toolkit.getDefaultToolkit().getScreenSize().height;

In my application, I am painting some items on the screen. And to determine the position, I use these values for width and height (because I want a particular item at the very bottom).

But, I'm finding that it is going off the screen, even though it's position doesn't exceed what the value for the height of my screen is.

Then, I realized I'm on a Mac, and the window that pops up for the Java application starts below the little toolbar menu thing at the top of my Mac (you know, the thing that has the time, the battery, etc). Do I need to take the height of that bar into consideration in my application? If s开发者_运维技巧o, is there an easy way to say "if I'm on a mac, then subtract something from the height." Also, what is that value of the height of that Menu Bar?


To get the maximum usable area, minus taskbars and menu bars, use the following:

Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

From the docs:

Returns the maximum bounds for centered Windows. These bounds account for objects in the native windowing system such as task bars and menu bars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜