Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screen Size Question



On Sat, 16 Nov 2002 10:50:28 -0600 Robert Westlund <email@hidden> wrote:

What is the proper (cross-platform safe) way to get the *available*
screen size for a full-screen window?

The toolkit getScreenSize() method returns the full screen resolution
on OS X, whereas the actual available height for a full-screen frame is
about 22 pixels less than that, due to the menubar. Do I need to make
a JDirect or JNI call if my app is running on a Mac, or is there a
simple Java method or system property I can use?

You have to account for the frame's insets:

// Adjust frame dimensions for system-dependent menus/windows
Insets insets = this.getInsets();
width -= (insets.left + insets.right );
height -= (insets.top + insets.bottom);

You can simulate other platforms by overriding getInsets():

public Insets getInsets ()
{
// OverRide getInsets() method to specify desired padding.

// This app:
// return new Insets(9, 9, 9, 9); // top, left, bottom, right

// Windows:
return new Insets(41, 3, 20, 3);

// Macintosh:
// return new Insets(22, 0, 0, 0);
}

- Craig
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.