Window
object is a top-level window with no borders and no menubar. The default layout for a window is BorderLayout
. 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 Window
on a different screen device by constructing the Window
with {@link #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 setLocation
, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen
on a Window
returns virtual device coordinates. Call the getBounds
method of a GraphicsConfiguration
to find its origin in the virtual coordinate system.
The following code sets the location of a Window
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 GraphicsConfiguration
.
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 Window
s, Frame
s, and Dialog
s) are under the control of the desktop's window management system. Calls to setLocation
, setSize
, and 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 returned by getBounds
, getLocation
, getLocationOnScreen
, and 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 {@code Window} arbitrarily, but the window management system maysubsequently change its size and/or location when the {@code Window} is made visible. One or more {@code ComponentEvent}s will be generated to indicate the new geometry.
Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus. @author Sami Shaio @author Arthur van Hoff @see WindowEvent @see #addWindowListener @see ae.java.awt.BorderLayout @since JDK1.0
{@code}
name
attribute defines the name of the style which you can later use with {@link Skin#newWindow(String,Stage,String,int,int,String)}.titleFont
attribute references a {@link BitmapFont} by name, to be used to render the title string.titleFontColor
attribute references a {@link Color} by name, to be used to render the title string.background
attribute references a {@link NinePatch} by name, to be used as the Window's background.Windows can contain arbitrary Smart GWT components, configured via the {@link com.smartgwt.client.widgets.Window#getItems items} property. Windows may be {@link com.smartgwt.client.widgets.Window#getIsModal modal} or non-modal.
Windows provide a series of highly configurableand skinnable autoChildren including a header, various header controls, footer, and corner resizer.
The more specialized {@link com.smartgwt.client.widgets.Dialog} subclass of Window has additional functionality targetted atsimple prompts and confirmations, such as buttons with default actions, and single-method {@link com.smartgwt.client.util.isc#warn shortcuts} for common application dialogs.
The contents of a window is set using {@link #setContent(Component)} or byusing the {@link #Window(String,Component)} constructor.
A window can be positioned on the screen using absolute coordinates (pixels) or set to be centered using {@link #center()}
The caption is displayed in the window header.
In Vaadin versions prior to 7.0.0, Window was also used as application level windows. This function is now covered by the {@link UI} class.
@author Vaadin Ltd. @since 3.0Window
object is a top-level window with no borders and no menubar. The default layout for a window is BorderLayout
. 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 Window
on a different screen device by constructing the Window
with {@link #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 setLocation
, you must pass a virtual coordinate to this method. Similarly, calling getLocationOnScreen
on a Window
returns virtual device coordinates. Call the getBounds
method of a GraphicsConfiguration
to find its origin in the virtual coordinate system.
The following code sets the location of a Window
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 GraphicsConfiguration
.
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 Window
s, Frame
s, and Dialog
s) are under the control of the desktop's window management system. Calls to setLocation
, setSize
, and 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 returned by getBounds
, getLocation
, getLocationOnScreen
, and 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 {@code Window} arbitrarily, but the window management system maysubsequently change its size and/or location when the {@code Window} is made visible. One or more {@code ComponentEvent}s will be generated to indicate the new geometry.
Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus. @version 1.240, 03/15/06 @author Sami Shaio @author Arthur van Hoff @see WindowEvent @see #addWindowListener @see java.awt.BorderLayout @since JDK1.0
@author 王志亮 [qieqie.wang@gmail.com]
WindowManager.getCurrentWindow
@see WindowManager#getCurrentWindow
Creating a window involves the following steps:
Window
create
(optional)WindowManager.add
(optional)open
The JFace window framework (this package) consists of this class, Window
, the abstract base of all windows, and one concrete window classes (ApplicationWindow
) which may also be subclassed. Clients may define additional window subclasses as required.
The Window
class provides methods that subclasses may override to configure the window, including:
close
- extend to free other SWT resourcesconfigureShell
- extend or reimplement to set shell properties before window openscreateContents
- extend or reimplement to create controls before window opensgetInitialSize
- reimplement to give the initial size for the shellgetInitialLocation
- reimplement to give the initial location for the shellgetShellListener
- extend or reimplement to receive shell eventshandleFontChange
- reimplement to respond to font changes handleShellCloseEvent
- extend or reimplement to handle shell closingsUnlike other elements, each {@link Window} is an independent ID space(by implementing {@link org.zkoss.zk.ui.IdSpace}). It means a window and all its descendants forms a ID space and the ID of each of them is unique in this space. You could retrieve any of them in this space by calling {@link #getFellow}.
If a window X is a descendant of another window Y, X's descendants are not visible in Y's space. To retrieve a descendant, say Z, of X, you have to invoke Y.getFellow('X').getFellow('Z').
Events:
onMove, onOpen, onMaximize, onMinimize, and onClose.
Note: to have better performance, onOpen is sent only if a non-deferrable event listener is registered (see {@link org.zkoss.zk.ui.event.Deferrable}).
onMaximize
and onMinimize
are supported. (since 3.5.0)
onClose
is sent when the close button is pressed (if {@link #isClosable} is true). The window has to detach or hidethe window. By default, {@link #onClose} detaches the window. To preventit from detached, you have to call {@link org.zkoss.zk.ui.event.Event#stopPropagation}to prevent {@link #onClose} is called.
On the other hand, onOpen
is sent when a popup window (i.e., {@link #getMode} is popup) is closed due to user's activity(such as press ESC). This event is only a notification. In other words, the popup is hidden before the event is sent to the server. The application cannot prevent the window from being hidden.
Default {@link #getZclass}: z-window- {@link #getMode()}.(since 3.5.0) @author tomyeh
Unlike other elements, each {@link Window} is an independent ID space (byimplementing {@link IdSpace}). It means a window and all its descendants forms a ID space and the ID of each of them is unique in this space. You could retrieve any of them in this space by calling {@link #getFellow}.
If a window X is a descendant of another window Y, X's descendants are not visible in Y's space. To retrieve a descendant, say Z, of X, you have to invoke Y.getFellow('X').getFellow('Z').
Events:
onMove, onOpen, onMaximize, onMinimize, and onClose.
Note: to have better performance, onOpen is sent only if a non-deferrable event listener is registered (see {@link org.zkoss.zk.ui.event.Deferrable}).
onMaximize
and onMinimize
are supported. (since 3.5.0)
onClose
is sent when the close button is pressed (if {@link #isClosable} is true). The window has to detach or hide the window. Bydefault, {@link org.zkoss.zul.Window#onClose} detaches the window. To preventit from detached, you have to call {@link org.zkoss.zk.ui.event.Event#stopPropagation} to prevent{@link org.zkoss.zul.Window#onClose} is called.
On the other hand, onOpen
is sent when a popup window (i.e., {@link #getMode} is popup) is closed due to user's activity (such as pressESC). This event is only a notification. In other words, the popup is hidden before the event is sent to the server. The application cannot prevent the window from being hidden.
Default {@link #getZclass}: z-window- {@link #getMode()}.(since 3.5.0) @author tomyeh @since 3.5.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|