public class Window extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Window.ClosingEvent
Fired just before the browser window closes or navigates to a different
site.
|
static interface |
Window.ClosingHandler
Handler for
Window.ClosingEvent events. |
static class |
Window.Location
This class provides access to the browser's location's object.
|
static class |
Window.Navigator
This class provides access to the browser's navigator object.
|
static class |
Window.ScrollEvent
Fired when the browser window is scrolled.
|
static interface |
Window.ScrollHandler
Handler for
Window.ScrollEvent events. |
Modifier and Type | Method and Description |
---|---|
static HandlerRegistration |
addCloseHandler(CloseHandler<Window> handler)
Adds a
CloseEvent handler. |
static HandlerRegistration |
addResizeHandler(ResizeHandler handler)
Adds a
ResizeEvent handler. |
static void |
addWindowCloseListener(WindowCloseListener listener)
Deprecated.
use
addWindowClosingHandler(ClosingHandler) and
addCloseHandler(CloseHandler) instead |
static HandlerRegistration |
addWindowClosingHandler(Window.ClosingHandler handler)
Adds a
Window.ClosingEvent handler. |
static void |
addWindowResizeListener(WindowResizeListener listener)
Deprecated.
use
addResizeHandler(ResizeHandler) instead |
static HandlerRegistration |
addWindowScrollHandler(Window.ScrollHandler handler)
Adds a
Window.ScrollEvent handler. |
static void |
addWindowScrollListener(WindowScrollListener listener)
Deprecated.
use
addWindowScrollHandler(ScrollHandler)
instead |
static void |
alert(String msg)
Displays a message in a modal dialog box.
|
static boolean |
confirm(String msg)
Displays a message in a modal dialog box, along with the standard 'OK' and
'Cancel' buttons.
|
static void |
enableScrolling(boolean enable)
Use this method to explicitly disable the window's scrollbars.
|
static int |
getClientHeight()
Gets the height of the browser window's client area excluding the scroll
bar.
|
static int |
getClientWidth()
Gets the width of the browser window's client area excluding the vertical
scroll bar.
|
static int |
getScrollLeft()
Gets the window's scroll left.
|
static int |
getScrollTop()
Get the window's scroll top.
|
static String |
getTitle()
Gets the browser window's current title.
|
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.
|
static void |
moveTo(int x,
int y)
Moves a window's left and top edge to the specified coordinates.
|
static void |
open(String url,
String name,
String features)
Opens a new browser window.
|
static void |
print()
Prints the document in the window, as if the user had issued a "Print"
command.
|
static String |
prompt(String msg,
String initialValue)
Displays a request for information in a modal dialog box, along with the
standard 'OK' and 'Cancel' buttons.
|
static void |
removeWindowCloseListener(WindowCloseListener listener)
Deprecated.
|
static void |
removeWindowResizeListener(WindowResizeListener listener)
Deprecated.
|
static void |
removeWindowScrollListener(WindowScrollListener listener)
Deprecated.
|
static void |
resizeBy(int width,
int height)
Resizes the window by the specified width and height.
|
static void |
resizeTo(int width,
int height)
Resizes the window to the specified width and height.
|
static void |
scrollTo(int left,
int top)
Scroll the window to the specified position.
|
static void |
setMargin(String size)
Sets the size of the margins used within the window's client area.
|
static void |
setStatus(String status)
Sets the status text for the window, if permitted by the browser's
settings.
|
static void |
setTitle(String title)
Sets the browser window's title.
|
public static HandlerRegistration addCloseHandler(CloseHandler<Window> handler)
CloseEvent
handler.handler
- the handlerpublic static HandlerRegistration addResizeHandler(ResizeHandler handler)
ResizeEvent
handler.handler
- the handler@Deprecated public static void addWindowCloseListener(WindowCloseListener listener)
addWindowClosingHandler(ClosingHandler)
and
addCloseHandler(CloseHandler)
insteadlistener
- the listener to be informed when the window is closingpublic static HandlerRegistration addWindowClosingHandler(Window.ClosingHandler handler)
Window.ClosingEvent
handler.handler
- the handler@Deprecated public static void addWindowResizeListener(WindowResizeListener listener)
addResizeHandler(ResizeHandler)
insteadlistener
- the listener to be informed when the window is resizedpublic static HandlerRegistration addWindowScrollHandler(Window.ScrollHandler handler)
Window.ScrollEvent
handler.handler
- the handler@Deprecated public static void addWindowScrollListener(WindowScrollListener listener)
addWindowScrollHandler(ScrollHandler)
insteadlistener
- the listener to be informed when the window is scrolledpublic static void alert(String msg)
msg
- the message to be displayed.public static boolean confirm(String msg)
msg
- the message to be displayed.true
if 'OK' is clicked, false
if
'Cancel' is clicked.public static void enableScrolling(boolean enable)
enable
- false
to disable window scrollingpublic static int getClientHeight()
public static int getClientWidth()
public static int getScrollLeft()
public static int getScrollTop()
public static String getTitle()
public static void moveBy(int dx, int dy)
NOTE: In Chrome, this method only works with windows created by Window.open().
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 bypublic static void moveTo(int x, int y)
NOTE: In Chrome, this method only works with windows created by Window.open().
x
- The left coordinatey
- The top coordinatepublic static void open(String url, String name, String features)
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 windowpublic static void print()
public static String prompt(String msg, String initialValue)
msg
- the message to be displayedinitialValue
- the initial value in the dialog's text fieldnull
if 'Cancel' was pressed@Deprecated public static void removeWindowCloseListener(WindowCloseListener listener)
listener
- the listener to be removed@Deprecated public static void removeWindowResizeListener(WindowResizeListener listener)
listener
- the listener to be removed@Deprecated public static void removeWindowScrollListener(WindowScrollListener listener)
listener
- the listener to be removedpublic static void resizeBy(int width, int height)
NOTE: In most modern browsers, this method only works with windows created by Window.open() with a supplied width and height.
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 bypublic static void resizeTo(int width, int height)
NOTE: In most modern browsers, this method only works with windows created by Window.open() with a supplied width and height.
width
- The width of the window, in pixelsheight
- The height of the window, in pixelspublic static void scrollTo(int left, int top)
left
- the left scroll positiontop
- the top scroll positionpublic static void setMargin(String size)
size
- the window's new margin size, in CSS units.public static void setStatus(String status)
status
- the new message to display.public static void setTitle(String title)
title
- the new window title.Copyright © 2018. All rights reserved.