Package com.google.gwt.user.client
Class Window
- java.lang.Object
-
- com.google.gwt.user.client.Window
-
public class Window extends java.lang.ObjectThis class provides access to the browser window's methods, properties, and events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWindow.ClosingEventFired just before the browser window closes or navigates to a different site.static interfaceWindow.ClosingHandlerHandler forWindow.ClosingEventevents.static classWindow.LocationThis class provides access to the browser's location's object.static classWindow.NavigatorThis class provides access to the browser's navigator object.static classWindow.ScrollEventFired when the browser window is scrolled.static interfaceWindow.ScrollHandlerHandler forWindow.ScrollEventevents.
-
Field Summary
Fields Modifier and Type Field Description (package private) static com.google.gwt.user.client.Window.WindowHandlershandlers
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static HandlerRegistrationaddCloseHandler(CloseHandler<Window> handler)Adds aCloseEventhandler.static HandlerRegistrationaddResizeHandler(ResizeHandler handler)Adds aResizeEventhandler.static voidaddWindowCloseListener(WindowCloseListener listener)Deprecated.useaddWindowClosingHandler(ClosingHandler)andaddCloseHandler(CloseHandler)insteadstatic HandlerRegistrationaddWindowClosingHandler(Window.ClosingHandler handler)Adds aWindow.ClosingEventhandler.static voidaddWindowResizeListener(WindowResizeListener listener)Deprecated.useaddResizeHandler(ResizeHandler)insteadstatic HandlerRegistrationaddWindowScrollHandler(Window.ScrollHandler handler)Adds aWindow.ScrollEventhandler.static voidaddWindowScrollListener(WindowScrollListener listener)Deprecated.useaddWindowScrollHandler(ScrollHandler)insteadstatic voidalert(java.lang.String msg)Displays a message in a modal dialog box.static booleanconfirm(java.lang.String msg)Displays 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 intgetClientHeight()Gets the height of the browser window's client area excluding the scroll bar.static intgetClientWidth()Gets the width of the browser window's client area excluding the vertical scroll bar.static intgetScrollLeft()Gets the window's scroll left.static intgetScrollTop()Get the window's scroll top.static java.lang.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 java.lang.StringonClosing()(package private) static voidonResize()(package private) static voidonScroll()static voidopen(java.lang.String url, java.lang.String name, java.lang.String features)Opens a new browser window.static voidprint()Prints the document in the window, as if the user had issued a "Print" command.static java.lang.Stringprompt(java.lang.String msg, java.lang.String initialValue)Displays a request for information in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.static voidremoveWindowCloseListener(WindowCloseListener listener)Deprecated.static voidremoveWindowResizeListener(WindowResizeListener listener)Deprecated.static voidremoveWindowScrollListener(WindowScrollListener listener)Deprecated.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 voidsetMargin(java.lang.String size)Sets the size of the margins used within the window's client area.static voidsetStatus(java.lang.String status)Sets the status text for the window, if permitted by the browser's settings.static voidsetTitle(java.lang.String title)Sets the browser window's title.
-
-
-
Method Detail
-
addCloseHandler
public static HandlerRegistration addCloseHandler(CloseHandler<Window> handler)
Adds aCloseEventhandler.- Parameters:
handler- the handler- Returns:
- returns the handler registration
-
addResizeHandler
public static HandlerRegistration addResizeHandler(ResizeHandler handler)
Adds aResizeEventhandler.- Parameters:
handler- the handler- Returns:
- returns the handler registration
-
addWindowCloseListener
@Deprecated public static void addWindowCloseListener(WindowCloseListener listener)
Deprecated.useaddWindowClosingHandler(ClosingHandler)andaddCloseHandler(CloseHandler)insteadAdds a listener to receive window closing events.- Parameters:
listener- the listener to be informed when the window is closing
-
addWindowClosingHandler
public static HandlerRegistration addWindowClosingHandler(Window.ClosingHandler handler)
Adds aWindow.ClosingEventhandler.- Parameters:
handler- the handler- Returns:
- returns the handler registration
-
addWindowResizeListener
@Deprecated public static void addWindowResizeListener(WindowResizeListener listener)
Deprecated.useaddResizeHandler(ResizeHandler)insteadAdds a listener to receive window resize events.- Parameters:
listener- the listener to be informed when the window is resized
-
addWindowScrollHandler
public static HandlerRegistration addWindowScrollHandler(Window.ScrollHandler handler)
Adds aWindow.ScrollEventhandler.- Parameters:
handler- the handler- Returns:
- returns the handler registration
-
addWindowScrollListener
@Deprecated public static void addWindowScrollListener(WindowScrollListener listener)
Deprecated.useaddWindowScrollHandler(ScrollHandler)insteadAdds a listener to receive window scroll events.- Parameters:
listener- the listener to be informed when the window is scrolled
-
alert
public static void alert(java.lang.String msg)
Displays a message in a modal dialog box.- Parameters:
msg- the message to be displayed.
-
confirm
public static boolean confirm(java.lang.String msg)
Displays 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.
-
enableScrolling
public 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
-
getClientHeight
public static int getClientHeight()
Gets the height of the browser window's client area excluding the scroll bar.- Returns:
- the window's client height
-
getClientWidth
public static int getClientWidth()
Gets the width of the browser window's client area excluding the vertical scroll bar.- Returns:
- the window's client width
-
getScrollLeft
public static int getScrollLeft()
Gets the window's scroll left.- Returns:
- window's scroll left
-
getScrollTop
public static int getScrollTop()
Get the window's scroll top.- Returns:
- the window's scroll top
-
getTitle
public static java.lang.String getTitle()
Gets the browser window's current title.- Returns:
- the window's title.
-
moveBy
public 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 bydy- A positive or a negative number that specifies how many pixels to move the top edge by
-
moveTo
public 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 coordinatey- The top coordinate
-
open
public static void open(java.lang.String url, java.lang.String name, java.lang.String features)Opens a new browser window. The "name" and "features" arguments are specified here.- Parameters:
url- the URL that the new window will displayname- the name of the window (e.g. "_blank")features- the features to be enabled/disabled on this window
-
print
public static void print()
Prints the document in the window, as if the user had issued a "Print" command.
-
prompt
public static java.lang.String prompt(java.lang.String msg, java.lang.String initialValue)Displays a request for information in a modal dialog box, along with the standard 'OK' and 'Cancel' buttons.- Parameters:
msg- the message to be displayedinitialValue- 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
-
removeWindowCloseListener
@Deprecated public static void removeWindowCloseListener(WindowCloseListener listener)
Deprecated.Removes a window closing listener.- Parameters:
listener- the listener to be removed
-
removeWindowResizeListener
@Deprecated public static void removeWindowResizeListener(WindowResizeListener listener)
Deprecated.Removes a window resize listener.- Parameters:
listener- the listener to be removed
-
removeWindowScrollListener
@Deprecated public static void removeWindowScrollListener(WindowScrollListener listener)
Deprecated.Removes a window scroll listener.- Parameters:
listener- the listener to be removed
-
resizeBy
public 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 byheight- A positive or a negative number that specifies how many pixels to resize the height by
-
resizeTo
public 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 pixelsheight- The height of the window, in pixels
-
scrollTo
public static void scrollTo(int left, int top)Scroll the window to the specified position.- Parameters:
left- the left scroll positiontop- the top scroll position
-
setMargin
public static void setMargin(java.lang.String size)
Sets 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.
-
setStatus
public static void setStatus(java.lang.String status)
Sets the status text for the window, if permitted by the browser's settings.- Parameters:
status- the new message to display.
-
setTitle
public static void setTitle(java.lang.String title)
Sets the browser window's title.- Parameters:
title- the new window title.
-
onClosed
static void onClosed()
-
onClosing
static java.lang.String onClosing()
-
onResize
static void onResize()
-
onScroll
static void onScroll()
-
-