Window object is a top-level window with no borders and no
The default layout for a window is
A window must have either a frame, dialog, or another window defined as its owner when it's constructed.
In a multi-screen environment, you can create a
on a different screen device by constructing the
Window(Window, GraphicsConfiguration). The
GraphicsConfiguration object is one of the
GraphicsConfiguration objects of the target screen device.
In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of all configurations are relative to the virtual device coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device, negative coordinates are possible, as shown in the following figure.
In such an environment, when calling
you must pass a virtual coordinate to this method. Similarly,
getLocationOnScreen on a
virtual device coordinates. Call the
GraphicsConfiguration to find its origin in the virtual
The following code sets the location of a
at (10, 10) relative to the origin of the physical screen
of the corresponding
GraphicsConfiguration. If the
bounds of the
GraphicsConfiguration is not taken
into account, the
Window location would be set
at (10, 10) relative to the virtual-coordinate system and would appear
on the primary physical screen, which might be different from the
physical screen of the specified
Window w = new Window(Window owner, GraphicsConfiguration gc); Rectangle bounds = gc.getBounds(); w.setLocation(10 + bounds.x, 10 + bounds.y);
Note: the location and size of top-level windows (including
are under the control of the desktop's window management system.
setBounds are requests (not directives) which are
forwarded to the window management system. Every effort will be
made to honor such requests. However, in some cases the window
management system may ignore such requests, or modify the requested
geometry in order to place and size the
Window in a way
that more closely matches the desktop settings.
Due to the asynchronous nature of native event handling, the results
getSize might not
reflect the actual geometry of the Window on screen until the last
request has been processed. During the processing of subsequent
requests these values might change accordingly while the window
management system fulfills the requests.
An application may set the size and location of an invisible
Window arbitrarily, but the window management system may
subsequently change its size and/or location when the
Window is made visible. One or more
will be generated to indicate the new geometry.
Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus.