Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java

Table of Contents

NSScreen


Inherits from:
NSObject
Package:
com.apple.yellow.application


Class Description


An NSScreen object describes the attributes of a computer's monitor, or screen. An application may use an NSScreen object to retrieve information about a screen and use this information to decide what to display upon that screen. For example, an application may use the deepestScreen method to find out which of the available screens can best represent color and then may choose to display all of its windows on that screen.

The two main attributes of a screen are its depth and its dimensions. The depth method describes the screen depth (such as two-bit, eight-bit, or twelve-bit) and tells you if the screen can display color. The frame method gives the screen's dimensions and location as an NSRect.

The device description dictionary contains more complete information about the screen. Use NSScreen's deviceDescription method to access the dictionary, and use these keys to retrieve information about a screen:


Dictionary Key Value
DeviceResolution An NSValue that contains an NSSize which indicates the screen's resolution in dots per inch (dpi).
DeviceColorSpaceName The screen's color space name. See the NSGraphics class specification for a list of possible values.
DeviceBitsPerSample An NSNumber containing an integer that indicates the bit depth of screen images (2-bit, 8-bit, and so on).
DeviceIsScreen "YES" (a string), indicating the device is a screen.
DeviceSize An NSValue that contains an NSSize which indicates the screen's size in points.

The device description dictionary contains information about not only screens, but all other system devices such as printers and windows. There are other keys into the dictionary that you would use to obtain information about these other devices.

The application object should be created before you use the methods in this class, so that the application object can make the necessary connection to the Window System. You can make sure the application object exists by invoking NSApplication's sharedApplication method, which creates it if necessary. If you created your application with Project Builder, the application object is automatically created for you.




Method Types


Constructors
NSScreen
Getting NSScreens
mainScreen
deepestScreen
screens
Reading screen information
depth
frame
supportedWindowDepths
deviceDescription
visibleFrame


Constructors



NSScreen

public NSScreen()

Description forthcoming.


Static Methods



deepestScreen

public static NSScreen deepestScreen()

Returns an NSScreen object representing the screen that can best represent color. This method always returns an object, even if there is only one screen and it is not a color screen.

mainScreen

public static NSScreen mainScreen()

Returns an NSScreen object representing the main screen. The main screen is the screen with the key window.

screens

public static NSArray screens()

Returns an array of NSScreen objects representing all of the screens available on the system. Throws a WindowServerCommunicationException if the screens information can't be obtained from the window system.


Instance Methods



depth

public int depth()

Returns the screen's depth, including whether the screen can display color.

deviceDescription

public NSDictionary deviceDescription()

Returns the device dictionary as described in the class description.

frame

public NSRect frame()

Returns the dimensions and location of the screen in an NSRect.

supportedWindowDepths

public int[] supportedWindowDepths()

Returns a zero-terminated array of the window depths supported by the screen.

visibleFrame

public NSRect visibleFrame()

Returns the dimensions and location of the visible screen in an NSRect. The frame for the visible screen is adjusted according to the interface style. For example, the visible screen area does not include the menu bar.


Table of Contents