Package com.google.gwt.user.client
Class Window
java.lang.Object
com.google.gwt.user.client.Window
This class provides access to the browser window's methods, properties, and
 events.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classFired just before the browser window closes or navigates to a different site.static interfaceHandler forWindow.ClosingEventevents.static classThis class provides access to the browser's location's object.static classThis class provides access to the browser's navigator object.static classFired when the browser window is scrolled.static interfaceHandler forWindow.ScrollEventevents.
- 
Field SummaryFieldsModifier and TypeFieldDescription(package private) static com.google.gwt.user.client.Window.WindowHandlers
- 
Method SummaryModifier and TypeMethodDescriptionstatic HandlerRegistrationaddCloseHandler(CloseHandler<Window> handler) Deprecated.static HandlerRegistrationaddResizeHandler(ResizeHandler handler) Adds aResizeEventhandler.static voidaddWindowCloseListener(WindowCloseListener listener) Deprecated.useaddWindowClosingHandler(ClosingHandler)andaddCloseHandler(CloseHandler)insteadstatic HandlerRegistrationAdds aWindow.ClosingEventhandler.static voidaddWindowResizeListener(WindowResizeListener listener) Deprecated.useaddResizeHandler(ResizeHandler)insteadstatic HandlerRegistrationAdds aWindow.ScrollEventhandler.static voidaddWindowScrollListener(WindowScrollListener listener) Deprecated.useaddWindowScrollHandler(ScrollHandler)insteadstatic voidDisplays a message in a modal dialog box.static booleanDisplays a message in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.static voidenableScrolling(boolean enable) Use this method to explicitly disable the window's scrollbars.static intGets the height of the browser window's client area excluding the scroll bar.static intGets the width of the browser window's client area excluding the vertical scroll bar.static intGets the window's scroll left.static intGet the window's scroll top.static StringgetTitle()Gets the browser window's current title.static voidmoveBy(int dx, int dy) Moves a window's left and top edge to a specified number of pixels relative to its current coordinates.static voidmoveTo(int x, int y) Moves a window's left and top edge to the specified coordinates.(package private) static voidonClosed()(package private) static String(package private) static voidonResize()(package private) static voidonScroll()static voidOpens a new browser window.static voidprint()Prints the document in the window, as if the user had issued a "Print" command.static StringDisplays a request for information in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.static voidremoveWindowCloseListener(WindowCloseListener listener) Deprecated.static voidDeprecated.static voidDeprecated.static voidresizeBy(int width, int height) Resizes the window by the specified width and height.static voidresizeTo(int width, int height) Resizes the window to the specified width and height.static voidscrollTo(int left, int top) Scroll the window to the specified position.static voidSets the size of the margins used within the window's client area.static voidSets the status text for the window, if permitted by the browser's settings.static voidSets the browser window's title.
- 
Field Details- 
handlersstatic com.google.gwt.user.client.Window.WindowHandlers handlers
 
- 
- 
Method Details
- 
addWindowCloseListenerDeprecated.useaddWindowClosingHandler(ClosingHandler)andaddCloseHandler(CloseHandler)insteadAdds a listener to receive window closing events.- Parameters:
- listener- the listener to be informed when the window is closing
 
- 
addWindowClosingHandlerAdds aWindow.ClosingEventhandler.- Parameters:
- handler- the handler
- Returns:
- returns the handler registration
 
- 
addWindowResizeListenerDeprecated.useaddResizeHandler(ResizeHandler)insteadAdds a listener to receive window resize events.- Parameters:
- listener- the listener to be informed when the window is resized
 
- 
addWindowScrollHandlerAdds aWindow.ScrollEventhandler.- Parameters:
- handler- the handler
- Returns:
- returns the handler registration
 
- 
addWindowScrollListenerDeprecated.useaddWindowScrollHandler(ScrollHandler)insteadAdds a listener to receive window scroll events.- Parameters:
- listener- the listener to be informed when the window is scrolled
 
- 
alertDisplays a message in a modal dialog box.- Parameters:
- msg- the message to be displayed.
 
- 
confirmDisplays a message in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.- Parameters:
- msg- the message to be displayed.
- Returns:
- trueif 'OK' is clicked,- falseif 'Cancel' is clicked.
 
- 
enableScrollingpublic static void enableScrolling(boolean enable) Use this method to explicitly disable the window's scrollbars. Applications that choose to resize their user-interfaces to fit within the window's client area will normally want to disable window scrolling.- Parameters:
- enable-- falseto disable window scrolling
 
- 
getClientHeightpublic static int getClientHeight()Gets the height of the browser window's client area excluding the scroll bar.- Returns:
- the window's client height
 
- 
getClientWidthpublic static int getClientWidth()Gets the width of the browser window's client area excluding the vertical scroll bar.- Returns:
- the window's client width
 
- 
getScrollLeftpublic static int getScrollLeft()Gets the window's scroll left.- Returns:
- window's scroll left
 
- 
getScrollToppublic static int getScrollTop()Get the window's scroll top.- Returns:
- the window's scroll top
 
- 
getTitleGets the browser window's current title.- Returns:
- the window's title.
 
- 
moveBypublic static void moveBy(int dx, int dy) Moves a window's left and top edge to a specified number of pixels relative to its current coordinates.NOTE: In Chrome, this method only works with windows created by Window.open(). - Parameters:
- dx- A positive or a negative number that specifies how many pixels to move the left edge by
- dy- A positive or a negative number that specifies how many pixels to move the top edge by
 
- 
moveTopublic static void moveTo(int x, int y) Moves a window's left and top edge to the specified coordinates.NOTE: In Chrome, this method only works with windows created by Window.open(). - Parameters:
- x- The left coordinate
- y- The top coordinate
 
- 
openOpens a new browser window. The "name" and "features" arguments are specified here.- Parameters:
- url- the URL that the new window will display
- name- the name of the window (e.g. "_blank")
- features- the features to be enabled/disabled on this window
 
- 
printpublic static void print()Prints the document in the window, as if the user had issued a "Print" command.
- 
promptDisplays a request for information in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.- Parameters:
- msg- the message to be displayed
- initialValue- the initial value in the dialog's text field
- Returns:
- the value entered by the user if 'OK' was pressed, or
         nullif 'Cancel' was pressed
 
- 
removeWindowCloseListenerDeprecated.Removes a window closing listener.- Parameters:
- listener- the listener to be removed
 
- 
removeWindowResizeListenerDeprecated.Removes a window resize listener.- Parameters:
- listener- the listener to be removed
 
- 
removeWindowScrollListenerDeprecated.Removes a window scroll listener.- Parameters:
- listener- the listener to be removed
 
- 
resizeBypublic static void resizeBy(int width, int height) Resizes the window by the specified width and height. This method moves the bottom right corner of the window by the specified number of pixels defined. The top left corner will not be moved (it stays in its original coordinates).NOTE: In most modern browsers, this method only works with windows created by Window.open() with a supplied width and height. - Parameters:
- width- A positive or a negative number that specifies how many pixels to resize the width by
- height- A positive or a negative number that specifies how many pixels to resize the height by
 
- 
resizeTopublic static void resizeTo(int width, int height) Resizes the window to the specified width and height.NOTE: In most modern browsers, this method only works with windows created by Window.open() with a supplied width and height. - Parameters:
- width- The width of the window, in pixels
- height- The height of the window, in pixels
 
- 
scrollTopublic static void scrollTo(int left, int top) Scroll the window to the specified position.- Parameters:
- left- the left scroll position
- top- the top scroll position
 
- 
setMarginSets the size of the margins used within the window's client area. It is sometimes necessary to do this because some browsers, such as Internet Explorer, add margins by default, which can confound attempts to resize panels to fit exactly within the window.- Parameters:
- size- the window's new margin size, in CSS units.
 
- 
setStatusSets the status text for the window, if permitted by the browser's settings.- Parameters:
- status- the new message to display.
 
- 
setTitleSets the browser window's title.- Parameters:
- title- the new window title.
 
- 
onClosedstatic void onClosed()
- 
onClosing
- 
onResizestatic void onResize()
- 
onScrollstatic void onScroll()
 
unloadbrowser event, which is deprecated in all browsers.