com.vaadin.ui
Class Window

java.lang.Object
  extended by com.vaadin.ui.AbstractComponent
      extended by com.vaadin.ui.AbstractComponentContainer
          extended by com.vaadin.ui.Panel
              extended by com.vaadin.ui.Window
All Implemented Interfaces:
Action.Container, Action.Notifier, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, MethodEventSource, Paintable, ParameterHandler, Scrollable, Sizeable, URIHandler, VariableOwner, Component, Component.Focusable, ComponentContainer, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Serializable, EventListener

public class Window
extends Panel
implements URIHandler, ParameterHandler, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier

A component that represents an application (browser native) window or a sub window.

If the window is a application window or a sub window depends on how it is added to the application. Adding a Window to a Window using addWindow(Window) makes it a sub window and adding a Window to the Application using Application.addWindow(Window) makes it an application window.

An application window is the base of any view in a Vaadin application. All applications contain a main application window (set using Application.setMainWindow(Window) which is what is initially shown to the user. The contents of a window is set using Panel.setContent(ComponentContainer). The contents can in turn contain other components. For multi-tab applications there is one window instance per opened tab.

A sub window is floating popup style window that can be added to an application window. Like the application window its content is set using Panel.setContent(ComponentContainer). A sub window can be positioned on the screen using absolute coordinates (pixels). The default content of the Window is set to be suitable for application windows. For sub windows it might be necessary to set the size of the content to work as expected.

Window caption is displayed in the browser title bar for application level windows and in the window header for sub windows.

Certain methods in this class are only meaningful for sub windows and other parts only for application windows. These are marked using Sub window only and Application window only respectively in the javadoc.

Sub window is to be split into a separate component in Vaadin 7.

Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
 class Window.CloseEvent
           
static interface Window.CloseListener
          An interface used for listening to Window close events.
static class Window.CloseShortcut
          A ShortcutListener specifically made to define a keyboard shortcut that closes the window.
static class Window.Notification
          A notification message, used to display temporary messages to the user - for example "Document saved", or "Save failed".
 class Window.ResizeEvent
          Resize events are fired whenever the client-side fires a resize-event (e.g.
static interface Window.ResizeListener
          Listener for window resize events.
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.URIHandler
URIHandler.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.ParameterHandler
ParameterHandler.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener
 
Field Summary
static int BORDER_DEFAULT
          Application window only.
static int BORDER_MINIMAL
          Application window only.
static int BORDER_NONE
          Application window only.
protected  Window.CloseShortcut closeShortcut
           
 
Fields inherited from class com.vaadin.ui.Panel
actionManager, STYLE_LIGHT
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
Window()
          Creates a new unnamed window with a default layout.
Window(String caption)
          Creates a new unnamed window with a default layout and given title.
Window(String caption, ComponentContainer content)
          Creates a new unnamed window with the given content and title.
 
Method Summary
 void addComponent(Component c)
          Adds the component into this container.
 void addListener(FieldEvents.BlurListener listener)
          Note, that focus/blur listeners in Window class are only supported by sub windows.
 void addListener(FieldEvents.FocusListener listener)
          Note, that focus/blur listeners in Window class are only supported by sub windows.
 void addListener(Window.CloseListener listener)
          Adds a CloseListener to the window.
 void addListener(Window.ResizeListener listener)
          Add a resize listener.
 void addParameterHandler(ParameterHandler handler)
          Application window only.
 void addURIHandler(URIHandler handler)
          Application window only.
 void addWindow(Window window)
          Adds a window inside another window.
 void attach()
          Notifies the child components and subwindows that the window is attached to the application.
 void bringToFront()
          If there are currently several sub windows visible, calling this method makes this window topmost.
 void center()
          Sets this window to be centered relative to its parent window.
 void changeVariables(Object source, Map<String,Object> variables)
          Called when one or more variables handled by the implementing class are changed.
protected  void close()
          Method that handles window closing (from UI).
 void detach()
          Notifies the child components and subwindows that the window is detached from the application.
 void executeJavaScript(String script)
          Executes JavaScript in this window.
protected  void fireClose()
           
protected  void fireResize()
          Fire the resize event.
 void focus()
          Moves keyboard focus to the component. If the window is a sub-window focusing will cause the sub-window to be brought on top of other sub-windows on gain keyboard focus.
 Application getApplication()
          Gets the application object to which the component is attached.
 int getBorder()
          Returns the border style of the window.
 int getBrowserWindowHeight()
          Gets the height of the viewport area of the browser window where this window is displayed.
 int getBrowserWindowWidth()
          Gets the width of the viewport area of the browser window where this window is displayed.
 Set<Window> getChildWindows()
          Get the set of all child windows.
 String getName()
          Application window only.
 Window getParent()
          Gets the parent component of the window.
 int getPositionX()
          Gets the distance of Window left border in pixels from left border of the containing (main window).
 int getPositionY()
          Gets the distance of Window top border in pixels from top border of the containing (main window).
 Terminal getTerminal()
          Application window only.
 String getTheme()
          Application window only.
 URL getURL()
          Gets the full URL of the window.
 Window getWindow()
          Gets the parent window of the component.
 void handleParameters(Map<String,String[]> parameters)
          Application window only.
 DownloadStream handleURI(URL context, String relativeUri)
          Application window only.
 boolean isClosable()
          Returns the closable status of the sub window.
 boolean isDraggable()
          Indicates whether a sub window can be dragged or not.
 boolean isModal()
           
 boolean isResizable()
           
 boolean isResizeLazy()
           
 void open(Resource resource)
          Opens the given resource in this window.
 void open(Resource resource, String windowName)
          Opens the given resource in a window with the given name.
 void open(Resource resource, String windowName, boolean tryToOpenAsPopup)
          Opens the given resource in a window with the given name and optionally tries to force the resource to open in a new window instead of a new tab.
 void open(Resource resource, String windowName, int width, int height, int border)
          Opens the given resource in a window with the given size, border and name.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void removeCloseShortcut()
          Removes the keyboard shortcut previously set with setCloseShortcut(int, int...).
 void removeListener(FieldEvents.BlurListener listener)
          Removes a BlurListener from the Component.
 void removeListener(FieldEvents.FocusListener listener)
          Removes a FocusListener from the Component.
 void removeListener(Window.CloseListener listener)
          Removes the CloseListener from the window.
 void removeListener(Window.ResizeListener listener)
          Remove a resize listener.
 void removeParameterHandler(ParameterHandler handler)
          Application window only.
 void removeURIHandler(URIHandler handler)
          Application window only.
 boolean removeWindow(Window window)
          Remove the given subwindow from this window.
 void scrollIntoView(Component component)
          Scrolls any component between the component and window to a suitable position so the component is visible to the user.
 void setApplication(Application application)
          Sets the application this window is attached to.
 void setBorder(int border)
          Sets the border style for this window.
 void setClosable(boolean closable)
          Sets the closable status for the sub window.
 void setCloseShortcut(int keyCode, int... modifiers)
          Makes is possible to close the window by pressing the given ShortcutAction.KeyCode and (optional) ShortcutAction.ModifierKeys.
Note that this shortcut only reacts while the window has focus, closing itself - if you want to close a subwindow from a parent window, use Panel.addAction(com.vaadin.event.Action) of the parent window instead.
 void setDraggable(boolean draggable)
          Enables or disables that a sub window can be dragged (moved) by the user.
 void setModal(boolean modality)
          Sets sub-window modal, so that widgets behind it cannot be accessed.
 void setName(String name)
          Application window only.
 void setPositionX(int positionX)
          Sets the distance of Window left border in pixels from left border of the containing (main window).
 void setPositionY(int positionY)
          Sets the distance of Window top border in pixels from top border of the containing (main window).
 void setResizable(boolean resizeability)
          Sets sub-window resizable.
 void setResizeLazy(boolean resizeLazy)
          Should resize operations be lazy, i.e.
 void setTerminal(Terminal type)
          Sets the user terminal.
 void setTheme(String theme)
          Application window only.
 void showNotification(String caption)
          Shows a notification message on the middle of the window.
 void showNotification(String caption, int type)
          Shows a notification message the window.
 void showNotification(String caption, String description)
          Shows a notification consisting of a bigger caption and a smaller description on the middle of the window.
 void showNotification(String caption, String description, int type)
          Shows a notification consisting of a bigger caption and a smaller description.
 void showNotification(String caption, String description, int type, boolean htmlContentAllowed)
          Shows a notification consisting of a bigger caption and a smaller description.
 void showNotification(Window.Notification notification)
          Shows a notification message.
 
Methods inherited from class com.vaadin.ui.Panel
addAction, addActionHandler, addListener, componentAttachedToContainer, componentDetachedFromContainer, getActionManager, getComponentIterator, getContent, getLayout, getScrollLeft, getScrollOffsetX, getScrollOffsetY, getScrollTop, getTabIndex, isScrollable, removeAction, removeActionHandler, removeAllActionHandlers, removeAllComponents, removeComponent, removeListener, replaceComponent, requestRepaintAll, setCaption, setContent, setLayout, setScrollable, setScrollLeft, setScrollOffsetX, setScrollOffsetY, setScrollTop, setTabIndex
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener, setEnabled, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, childRequestedRepaint, getCaption, getIcon, getLocale, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
isImmediate
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits
 

Field Detail

BORDER_NONE

public static final int BORDER_NONE
Application window only. A border style used for opening resources in a window without a border.

See Also:
Constant Field Values

BORDER_MINIMAL

public static final int BORDER_MINIMAL
Application window only. A border style used for opening resources in a window with a minimal border.

See Also:
Constant Field Values

BORDER_DEFAULT

public static final int BORDER_DEFAULT
Application window only. A border style that indicates that the default border style should be used when opening resources.

See Also:
Constant Field Values

closeShortcut

protected Window.CloseShortcut closeShortcut
Constructor Detail

Window

public Window()
Creates a new unnamed window with a default layout.


Window

public Window(String caption)
Creates a new unnamed window with a default layout and given title.

Parameters:
caption - the title of the window.

Window

public Window(String caption,
              ComponentContainer content)
Creates a new unnamed window with the given content and title.

Parameters:
caption - the title of the window.
content - the contents of the window
Method Detail

addComponent

public void addComponent(Component c)
Description copied from class: Panel
Adds the component into this container.

Specified by:
addComponent in interface ComponentContainer
Overrides:
addComponent in class Panel
Parameters:
c - the component to be added.
See Also:
AbstractComponentContainer.addComponent(com.vaadin.ui.Component)

getTerminal

public Terminal getTerminal()
Application window only. Gets the user terminal.

Returns:
the user terminal

getWindow

public Window getWindow()
Gets the parent window of the component.

This is always the window itself.

This method is not meant to be overridden. Due to CDI requirements we cannot declare it as final even though it should be final.

Specified by:
getWindow in interface Component
Overrides:
getWindow in class AbstractComponent
Returns:
the window itself
See Also:
Component.getWindow()

getApplication

public Application getApplication()
Description copied from class: AbstractComponent
Gets the application object to which the component is attached.

The method will return null if the component is not currently attached to an application. This is often a problem in constructors of regular components and in the initializers of custom composite components. A standard workaround is to move the problematic initialization to AbstractComponent.attach(), as described in the documentation of the method.

This method is not meant to be overridden. Due to CDI requirements we cannot declare it as final even though it should be final.

Specified by:
getApplication in interface Component
Overrides:
getApplication in class AbstractComponent
Returns:
the parent application of the component or null.
See Also:
AbstractComponent.attach()

getParent

public Window getParent()
Gets the parent component of the window.

The parent of an application window is always null. The parent of a sub window is the application window the sub window is attached to.

This method is not meant to be overridden. Due to CDI requirements we cannot declare it as final even though it should be final.

Specified by:
getParent in interface Component
Overrides:
getParent in class AbstractComponent
Returns:
the parent window
See Also:
Component.getParent()

addURIHandler

public void addURIHandler(URIHandler handler)
Application window only. Adds a new URI handler to this window. If this is a sub window the URI handler is attached to the parent application window.

Parameters:
handler - the URI handler to add.

removeURIHandler

public void removeURIHandler(URIHandler handler)
Application window only. Removes the URI handler from this window. If this is a sub window the URI handler is removed from the parent application window.

Parameters:
handler - the URI handler to remove.

handleURI

public DownloadStream handleURI(URL context,
                                String relativeUri)
Application window only. Handles an URI by passing the URI to all URI handlers defined using addURIHandler(URIHandler). All URI handlers are called for each URI but no more than one handler may return a DownloadStream. If more than one stream is returned a RuntimeException is thrown.

Specified by:
handleURI in interface URIHandler
Parameters:
context - The URL of the application
relativeUri - The URI relative to context
Returns:
A DownloadStream that one of the URI handlers returned, null if no DownloadStream was returned.

addParameterHandler

public void addParameterHandler(ParameterHandler handler)
Application window only. Adds a new parameter handler to this window. If this is a sub window the parameter handler is attached to the parent application window.

Parameters:
handler - the parameter handler to add.

removeParameterHandler

public void removeParameterHandler(ParameterHandler handler)
Application window only. Removes the parameter handler from this window. If this is a sub window the parameter handler is removed from the parent application window.

Parameters:
handler - the parameter handler to remove.

handleParameters

public void handleParameters(Map<String,String[]> parameters)
Application window only. Handles parameters by passing the parameters to all ParameterHandlers defined using addParameterHandler(ParameterHandler). All ParameterHandlers are called for each set of parameters.

Specified by:
handleParameters in interface ParameterHandler
Parameters:
parameters - a map containing the parameter names and values
See Also:
ParameterHandler.handleParameters(Map)

getTheme

public String getTheme()
Application window only. Gets the theme for this window.

If the theme for this window is not explicitly set, the application theme name is returned. If the window is not attached to an application, the terminal default theme name is returned. If the theme name cannot be determined, null is returned

Subwindows do not support themes and return the theme used by the parent window

Returns:
the name of the theme used for the window

setTheme

public void setTheme(String theme)
Application window only. Sets the name of the theme to use for this window. Changing the theme will cause the page to be reloaded.

Parameters:
theme - the name of the new theme for this window or null to use the application theme.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The more general AbstractComponent.paint(PaintTarget) method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Overrides:
paintContent in class Panel
Parameters:
target - the target UIDL stream where the component should paint itself to
Throws:
PaintException - if the paint operation failed.

scrollIntoView

public void scrollIntoView(Component component)
                    throws IllegalArgumentException
Scrolls any component between the component and window to a suitable position so the component is visible to the user. The given component must be inside this window.

Parameters:
component - the component to be scrolled into view
Throws:
IllegalArgumentException - if component is not inside this window

open

public void open(Resource resource)
Opens the given resource in this window. The contents of this Window is replaced by the Resource.

Parameters:
resource - the resource to show in this window

open

public void open(Resource resource,
                 String windowName)
Opens the given resource in a window with the given name. Equivalent to open (resource, windowName, true) .

The supplied windowName is used as the target name in a window.open call in the client. This means that special values such as "_blank", "_self", "_top", "_parent" have special meaning. An empty or null window name is also a special case.

"", null and "_self" as windowName all causes the resource to be opened in the current window, replacing any old contents. For downloadable content you should avoid "_self" as "_self" causes the client to skip rendering of any other changes as it considers them irrelevant (the page will be replaced by the resource). This can speed up the opening of a resource, but it might also put the client side into an inconsistent state if the window content is not completely replaced e.g., if the resource is downloaded instead of displayed in the browser.

"_blank" as windowName causes the resource to always be opened in a new window or tab (depends on the browser and browser settings).

"_top" and "_parent" as windowName works as specified by the HTML standard.

Any other windowName will open the resource in a window with that name, either by opening a new window/tab in the browser or by replacing the contents of an existing window with that name.

Parameters:
resource - the resource.
windowName - the name of the window.

open

public void open(Resource resource,
                 String windowName,
                 boolean tryToOpenAsPopup)
Opens the given resource in a window with the given name and optionally tries to force the resource to open in a new window instead of a new tab.

The supplied windowName is used as the target name in a window.open call in the client. This means that special values such as "_blank", "_self", "_top", "_parent" have special meaning. An empty or null window name is also a special case.

"", null and "_self" as windowName all causes the resource to be opened in the current window, replacing any old contents. For downloadable content you should avoid "_self" as "_self" causes the client to skip rendering of any other changes as it considers them irrelevant (the page will be replaced by the resource). This can speed up the opening of a resource, but it might also put the client side into an inconsistent state if the window content is not completely replaced e.g., if the resource is downloaded instead of displayed in the browser.

"_blank" as windowName causes the resource to always be opened in a new window or tab (depends on the browser and browser settings).

"_top" and "_parent" as windowName works as specified by the HTML standard.

Any other windowName will open the resource in a window with that name, either by opening a new window/tab in the browser or by replacing the contents of an existing window with that name.

If windowName is set to open the resource in a new window or tab and tryToOpenAsPopup is true, this method attempts to force the browser to open a new window instead of a tab. NOTE: This is a best-effort attempt and may not work reliably with all browsers and different pop-up preferences. With most browsers using default settings, tryToOpenAsPopup works properly.

Parameters:
resource - the resource.
windowName - the name of the window.
tryToOpenAsPopup - Whether to try to force the resource to be opened in a new window

open

public void open(Resource resource,
                 String windowName,
                 int width,
                 int height,
                 int border)
Opens the given resource in a window with the given size, border and name. For more information on the meaning of windowName, see open(Resource, String).

Parameters:
resource - the resource.
windowName - the name of the window.
width - the width of the window in pixels
height - the height of the window in pixels
border - the border style of the window. See Window.BORDER_* constants

getURL

public URL getURL()
Gets the full URL of the window. The returned URL is window specific and can be used to directly refer to the window.

Note! This method can not be used for portlets.

Returns:
the URL of the window or null if the window is not attached to an application

getName

public String getName()
Application window only. Gets the unique name of the window. The name of the window is used to uniquely identify it.

The name also determines the URL that can be used for direct access to a window. All windows can be accessed through http://host:port/app/win where http://host:port/app is the application URL (as returned by Application.getURL() and win is the window name.

Note! Portlets do not support direct window access through URLs.

Returns:
the Name of the Window.

getBorder

public int getBorder()
Returns the border style of the window.

Returns:
the border style for the window
See Also:
setBorder(int)

setBorder

public void setBorder(int border)
Sets the border style for this window. Valid values are BORDER_NONE, BORDER_MINIMAL, BORDER_DEFAULT.

Note! Setting this seems to currently have no effect whatsoever on the window.

Parameters:
border - the border style to set

setApplication

public void setApplication(Application application)
Sets the application this window is attached to.

This method is called by the framework and should not be called directly from application code. Application.addWindow(Window) should be used to add the window to an application and Application.removeWindow(Window) to remove the window from the application.

This method invokes Component.attach() and Component.detach() methods when necessary.

Parameters:
application - the application the window is attached to

setName

public void setName(String name)
             throws IllegalStateException
Application window only. Sets the unique name of the window. The name of the window is used to uniquely identify it inside the application.

The name also determines the URL that can be used for direct access to a window. All windows can be accessed through http://host:port/app/win where http://host:port/app is the application URL (as returned by Application.getURL() and win is the window name.

This method can only be called before the window is added to an application.

Note! Portlets do not support direct window access through URLs.

Parameters:
name - the new name for the window or null if the application should automatically assign a name to it
Throws:
IllegalStateException - if the window is attached to an application

setTerminal

public void setTerminal(Terminal type)
Sets the user terminal. Used by the terminal adapter, should never be called from application code.

Parameters:
type - the terminal to set.

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Description copied from class: Panel
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class Panel
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.
See Also:
VariableOwner.changeVariables(Object, Map)

close

protected void close()
Method that handles window closing (from UI).

By default, sub-windows are removed from their respective parent windows and thus visually closed on browser-side. Browser-level windows also closed on the client-side, but they are not implicitly removed from the application.

To explicitly close a sub-window, use removeWindow(Window). To react to a window being closed (after it is closed), register a Window.CloseListener.


getPositionX

public int getPositionX()
Gets the distance of Window left border in pixels from left border of the containing (main window).

Returns:
the Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.
Since:
4.0.0

setPositionX

public void setPositionX(int positionX)
Sets the distance of Window left border in pixels from left border of the containing (main window).

Parameters:
positionX - the Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.
Since:
4.0.0

getPositionY

public int getPositionY()
Gets the distance of Window top border in pixels from top border of the containing (main window).

Returns:
Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified .
Since:
4.0.0

setPositionY

public void setPositionY(int positionY)
Sets the distance of Window top border in pixels from top border of the containing (main window).

Parameters:
positionY - the Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
Since:
4.0.0

addListener

public void addListener(Window.CloseListener listener)
Adds a CloseListener to the window. For a sub window the CloseListener is fired when the user closes it (clicks on the close button). For a browser level window the CloseListener is fired when the browser level window is closed. Note that closing a browser level window does not mean it will be destroyed. Also note that Opera does not send events like all other browsers and therefore the close listener might not be called if Opera is used.

Since Vaadin 6.5, removing windows using removeWindow(Window) does fire the CloseListener.

Parameters:
listener - the CloseListener to add.

removeListener

public void removeListener(Window.CloseListener listener)
Removes the CloseListener from the window.

For more information on CloseListeners see Window.CloseListener.

Parameters:
listener - the CloseListener to remove.

fireClose

protected void fireClose()

addListener

public void addListener(Window.ResizeListener listener)
Add a resize listener.

Parameters:
listener -

removeListener

public void removeListener(Window.ResizeListener listener)
Remove a resize listener.

Parameters:
listener -

fireResize

protected void fireResize()
Fire the resize event.


addWindow

public void addWindow(Window window)
               throws IllegalArgumentException,
                      NullPointerException
Adds a window inside another window.

Adding windows inside another window creates "subwindows". These windows should not be added to application directly and are not accessible directly with any url. Addding windows implicitly sets their parents.

Only one level of subwindows are supported. Thus you can add windows inside such windows whose parent is null.

Parameters:
window -
Throws:
IllegalArgumentException - if a window is added inside non-application level window.
NullPointerException - if the given Window is null.

removeWindow

public boolean removeWindow(Window window)
Remove the given subwindow from this window. Since Vaadin 6.5, Window.CloseListeners are called also when explicitly removing a window by calling this method. Since Vaadin 6.5, returns a boolean indicating if the window was removed or not.

Parameters:
window - Window to be removed.
Returns:
true if the subwindow was removed, false otherwise

bringToFront

public void bringToFront()
If there are currently several sub windows visible, calling this method makes this window topmost.

This method can only be called if this window is a sub window and connected a top level window. Else an illegal state exception is thrown. Also if there are modal windows and this window is not modal, and illegal state exception is thrown.

Note, this API works on sub windows only. Browsers can't reorder OS windows.


getChildWindows

public Set<Window> getChildWindows()
Get the set of all child windows.

Returns:
Set of child windows.

setModal

public void setModal(boolean modality)
Sets sub-window modal, so that widgets behind it cannot be accessed. Note: affects sub-windows only.

Parameters:
modality - true if modality is to be turned on

isModal

public boolean isModal()
Returns:
true if this window is modal.

setResizable

public void setResizable(boolean resizeability)
Sets sub-window resizable. Note: affects sub-windows only.

Parameters:
resizable - true if resizability is to be turned on

isResizable

public boolean isResizable()
Returns:
true if window is resizable by the end-user, otherwise false.

isResizeLazy

public boolean isResizeLazy()
Returns:
true if a delay is used before recalculating sizes, false if sizes are recalculated immediately.

setResizeLazy

public void setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. should there be a delay before layout sizes are recalculated. Speeds up resize operations in slow UIs with the penalty of slightly decreased usability. Note, some browser send false resize events for the browser window and are therefore always lazy.

Parameters:
resizeLazy - true to use a delay before recalculating sizes, false to calculate immediately.

center

public void center()
Sets this window to be centered relative to its parent window. Affects sub-windows only. If the window is resized as a result of the size of its content changing, it will keep itself centered as long as its position is not explicitly changed programmatically or by the user.

NOTE: This method has several issues as currently implemented. Please refer to http://dev.vaadin.com/ticket/8971 for details.


showNotification

public void showNotification(String caption)
Shows a notification message on the middle of the window. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.

Parameters:
caption - The message
See Also:
showNotification(com.vaadin.ui.Window.Notification), Window.Notification

showNotification

public void showNotification(String caption,
                             int type)
Shows a notification message the window. The position and behavior of the message depends on the type, which is one of the basic types defined in Window.Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.

Parameters:
caption - The message
type - The message type
See Also:
showNotification(com.vaadin.ui.Window.Notification), Window.Notification

showNotification

public void showNotification(String caption,
                             String description)
Shows a notification consisting of a bigger caption and a smaller description on the middle of the window. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.

Parameters:
caption - The caption of the message
description - The message description
See Also:
showNotification(com.vaadin.ui.Window.Notification), Window.Notification

showNotification

public void showNotification(String caption,
                             String description,
                             int type)
Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in Window.Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.

Parameters:
caption - The caption of the message
description - The message description
type - The message type
See Also:
showNotification(com.vaadin.ui.Window.Notification), Window.Notification

showNotification

public void showNotification(String caption,
                             String description,
                             int type,
                             boolean htmlContentAllowed)
Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in Window.Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to avoid XSS vulnerabilities if html content is allowed.

Parameters:
caption - The message caption
description - The message description
type - The type of message
htmlContentAllowed - Whether html in the caption and description should be displayed as html or as plain text
See Also:
showNotification(com.vaadin.ui.Window.Notification), Window.Notification

showNotification

public void showNotification(Window.Notification notification)
Shows a notification message.

Parameters:
notification - The notification message to show
See Also:
Window.Notification, showNotification(String), showNotification(String, int), showNotification(String, String), showNotification(String, String, int)

executeJavaScript

public void executeJavaScript(String script)
Executes JavaScript in this window.

This method allows one to inject javascript from the server to client. A client implementation is not required to implement this functionality, but currently all web-based clients do implement this.

Executing javascript this way often leads to cross-browser compatibility issues and regressions that are hard to resolve. Use of this method should be avoided and instead it is recommended to create new widgets with GWT. For more info on creating own, reusable client-side widgets in Java, read the corresponding chapter in Book of Vaadin.

Parameters:
script - JavaScript snippet that will be executed.

isClosable

public boolean isClosable()
Returns the closable status of the sub window. If a sub window is closable it typically shows an X in the upper right corner. Clicking on the X sends a close event to the server. Setting closable to false will remove the X from the sub window and prevent the user from closing the window. Note! For historical reasons readonly controls the closability of the sub window and therefore readonly and closable affect each other. Setting readonly to true will set closable to false and vice versa.

Closable only applies to sub windows, not to browser level windows.

Returns:
true if the sub window can be closed by the user.

setClosable

public void setClosable(boolean closable)
Sets the closable status for the sub window. If a sub window is closable it typically shows an X in the upper right corner. Clicking on the X sends a close event to the server. Setting closable to false will remove the X from the sub window and prevent the user from closing the window. Note! For historical reasons readonly controls the closability of the sub window and therefore readonly and closable affect each other. Setting readonly to true will set closable to false and vice versa.

Closable only applies to sub windows, not to browser level windows.

Parameters:
closable - determines if the sub window can be closed by the user.

isDraggable

public boolean isDraggable()
Indicates whether a sub window can be dragged or not. By default a sub window is draggable.

Draggable only applies to sub windows, not to browser level windows.

Parameters:
draggable - true if the sub window can be dragged by the user

setDraggable

public void setDraggable(boolean draggable)
Enables or disables that a sub window can be dragged (moved) by the user. By default a sub window is draggable.

Draggable only applies to sub windows, not to browser level windows.

Parameters:
draggable - true if the sub window can be dragged by the user

setCloseShortcut

public void setCloseShortcut(int keyCode,
                             int... modifiers)
Makes is possible to close the window by pressing the given ShortcutAction.KeyCode and (optional) ShortcutAction.ModifierKeys.
Note that this shortcut only reacts while the window has focus, closing itself - if you want to close a subwindow from a parent window, use Panel.addAction(com.vaadin.event.Action) of the parent window instead.

Parameters:
keyCode - the keycode for invoking the shortcut
modifiers - the (optional) modifiers for invoking the shortcut, null for none

removeCloseShortcut

public void removeCloseShortcut()
Removes the keyboard shortcut previously set with setCloseShortcut(int, int...).


addListener

public void addListener(FieldEvents.FocusListener listener)
Note, that focus/blur listeners in Window class are only supported by sub windows. Also note that Window is not considered focused if its contained component currently has focus.

Specified by:
addListener in interface FieldEvents.FocusNotifier
See Also:
FieldEvents.FocusNotifier.addListener(com.vaadin.event.FieldEvents.FocusListener)

removeListener

public void removeListener(FieldEvents.FocusListener listener)
Description copied from interface: FieldEvents.FocusNotifier
Removes a FocusListener from the Component.

Specified by:
removeListener in interface FieldEvents.FocusNotifier
See Also:
FieldEvents.FocusListener

addListener

public void addListener(FieldEvents.BlurListener listener)
Note, that focus/blur listeners in Window class are only supported by sub windows. Also note that Window is not considered focused if its contained component currently has focus.

Specified by:
addListener in interface FieldEvents.BlurNotifier
See Also:
FieldEvents.BlurNotifier.addListener(com.vaadin.event.FieldEvents.BlurListener)

removeListener

public void removeListener(FieldEvents.BlurListener listener)
Description copied from interface: FieldEvents.BlurNotifier
Removes a BlurListener from the Component.

Specified by:
removeListener in interface FieldEvents.BlurNotifier
See Also:
FieldEvents.BlurListener

focus

public void focus()
Moves keyboard focus to the component. Component.Focusable.focus() If the window is a sub-window focusing will cause the sub-window to be brought on top of other sub-windows on gain keyboard focus.

Specified by:
focus in interface Component.Focusable
Overrides:
focus in class Panel
See Also:
FieldEvents, FieldEvents.FocusEvent, FieldEvents.FocusListener, FieldEvents.BlurEvent, FieldEvents.BlurListener

attach

public void attach()
Notifies the child components and subwindows that the window is attached to the application.

Specified by:
attach in interface Component
Overrides:
attach in class Panel
See Also:
Component.attach()

detach

public void detach()
Notifies the child components and subwindows that the window is detached from the application.

Specified by:
detach in interface Component
Overrides:
detach in class Panel
See Also:
Component.detach()

getBrowserWindowHeight

public int getBrowserWindowHeight()
Gets the height of the viewport area of the browser window where this window is displayed.

Returns:
the browser viewport height in pixels

getBrowserWindowWidth

public int getBrowserWindowWidth()
Gets the width of the viewport area of the browser window where this window is displayed.

Returns:
the browser viewport width in pixels


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.