Google Web Toolkit
Search Google Code:

# Class DOM

public class DOM
extends Object
This class provides a set of static methods that allow you to manipulate the browser's Document Object Model (DOM). It contains methods for manipulating both elements and events.

## Methods

addEventPreview(EventPreview) | Adds an event preview to the preview stack.
appendChild(Element, Element) | Appends one element to another's list of children.
compare(Element, Element) | Compares two elements for equality (note that reference equality is not sufficient to determine equality among elements on most browsers).
createAnchor() | Creates an HTML A element.
createButton() | Creates an HTML BUTTON element.
createCaption() | Creates an HTML CAPTION element.
createCol() | Creates an HTML COL element.
createColGroup() | Creates an HTML COLGROUP element.
createDiv() | Creates an HTML DIV element.
createElement(String) | Creates an HTML element.
createFieldSet() | Creates an HTML FIELDSET element.
createForm() | Creates an HTML FORM element.
createIFrame() | Creates an HTML IFRAME element.
createImg() | Creates an HTML IMG element.
createInputCheck() | Creates an HTML INPUT type='CHECK' element.
createInputPassword() | Creates an HTML INPUT type='PASSWORD' element.
createInputRadio(String) | Creates an HTML INPUT type='RADIO' element.
createInputText() | Creates an HTML INPUT type='TEXT' element.
createLabel() | Creates an HTML LABEL element.
createLegend() | Creates an HTML LEGEND element.
createOptions() | Creates an HTML OPTIONS element.
createSelect() | Creates a single-selection HTML SELECT element.
createSelect(boolean) | Creates an HTML SELECT element.
createSpan() | Creates an HTML SPAN element.
createTable() | Creates an HTML TABLE element.
createTBody() | Creates an HTML TBODY element.
createTD() | Creates an HTML TD element.
createTextArea() | Creates an HTML TEXTAREA element.
createTFoot() | Creates an HTML TFOOT element.
createTH() | Creates an HTML TH element.
createTHead() | Creates an HTML THEAD element.
createTR() | Creates an HTML TR element.
eventCancelBubble(Event, boolean) | Cancels bubbling for the given event.
eventGetAltKey(Event) | Gets whether the ALT key was depressed when the given event occurred.
eventGetButton(Event) | Gets the mouse buttons that were depressed when the given event occurred.
eventGetClientX(Event) | Gets the mouse x-position within the browser window's client area.
eventGetClientY(Event) | Gets the mouse y-position within the browser window's client area.
eventGetCtrlKey(Event) | Gets whether the CTRL key was depressed when the given event occurred.
eventGetCurrentEvent() | Gets the current event that is being fired.
eventGetCurrentTarget(Event) | Gets the current target element of the given event.
eventGetFromElement(Event) | Gets the element from which the mouse pointer was moved (only valid for Event.ONMOUSEOVER).
eventGetKeyCode(Event) | Gets the key code associated with this event.
eventGetMetaKey(Event) | Gets whether the META key was depressed when the given event occurred.
eventGetMouseWheelVelocityY(Event) | Gets the velocity of the mouse wheel associated with the event along the Y axis.
eventGetRepeat(Event) | Gets the key-repeat state of this event.
eventGetScreenX(Event) | Gets the mouse x-position on the user's display.
eventGetScreenY(Event) | Gets the mouse y-position on the user's display.
eventGetShiftKey(Event) | Gets whether the shift key was depressed when the given event occurred.
eventGetTarget(Event) | Returns the element that was the actual target of the given event.
eventGetToElement(Event) | Gets the element to which the mouse pointer was moved (only valid for Event.ONMOUSEOUT).
eventGetType(Event) | Gets the enumerated type of this event (as defined in Event).
eventGetTypeString(Event) | Gets the type of the given event as a string.
eventPreventDefault(Event) | Prevents the browser from taking its default action for the given event.
eventSetKeyCode(Event, char) | Sets the key code associated with the given keyboard event.
eventToString(Event) | Returns a stringized version of the event.
getAbsoluteLeft(Element) | Gets an element's absolute left coordinate in the document's coordinate system.
getAbsoluteTop(Element) | Gets an element's absolute top coordinate in the document's coordinate system.
getAttribute(Element, String) | Gets any named attribute from an element, as a string.
getBooleanAttribute(Element, String) | Gets a boolean attribute on the given element.
getCaptureElement() | Gets the element that currently has mouse capture.
getChild(Element, int) | Gets an element's n-th child element.
getChildCount(Element) | Gets the number of child elements present in a given parent element.
getChildIndex(Element, Element) | Gets the index of a given child element within its parent.
getElementAttribute(Element, String) | Gets the named attribute from the element.
getElementById(String) | Gets the element associated with the given unique id within the entire document.
getElementProperty(Element, String) | Gets any named property from an element, as a string.
getElementPropertyBoolean(Element, String) | Gets any named property from an element, as a boolean.
getElementPropertyInt(Element, String) | Gets any named property from an element, as an int.
getEventsSunk(Element) | Gets the current set of events sunk by a given element.
getFirstChild(Element) | Gets the first child element of the given element.
getImgSrc(Element) | Gets the src attribute of an img element.
getInnerHTML(Element) | Gets an HTML representation of an element's children.
getInnerText(Element) | Gets the text contained within an element.
getIntAttribute(Element, String) | Gets an integer attribute on a given element.
getIntStyleAttribute(Element, String) | Gets an integer attribute on a given element's style.
getNextSibling(Element) | Gets an element's next sibling element.
getParent(Element) | Gets an element's parent element.
getStyleAttribute(Element, String) | Gets an attribute of the given element's style.
insertBefore(Element, Element, Element) | Inserts an element as a child of the given parent element, before another child of that parent.
insertChild(Element, Element, int) | Inserts an element as a child of the given parent element.
insertListItem(Element, String, String, int) | Creates an `<option>` element and inserts it as a child of the specified `<select>` element.
isOrHasChild(Element, Element) | Determine whether one element is equal to, or the child of, another.
releaseCapture(Element) | Releases mouse capture on the given element.
removeChild(Element, Element) | Removes a child element from the given parent element.
removeElementAttribute(Element, String) | Removes the named attribute from the given element.
removeEventPreview(EventPreview) | Removes an element from the preview stack.
scrollIntoView(Element) | Scrolls the given element into view.
setAttribute(Element, String, String) | Sets an attribute on the given element.
setBooleanAttribute(Element, String, boolean) | Sets a boolean attribute on the given element.
setCapture(Element) | Sets mouse-capture on the given element.
setElementAttribute(Element, String, String) | Sets an attribute on a given element.
setElementProperty(Element, String, String) | Sets a property on the given element.
setElementPropertyBoolean(Element, String, boolean) | Sets a boolean property on the given element.
setElementPropertyInt(Element, String, int) | Sets an int property on the given element.
setEventListener(Element, EventListener) | Sets the EventListener to receive events for the given element.
setImgSrc(Element, String) | Sets the src attribute of an img element.
setInnerHTML(Element, String) | Sets the HTML contained within an element.
setInnerText(Element, String) | Sets the text contained within an element.
setIntAttribute(Element, String, int) | Sets an integer attribute on the given element.
setIntStyleAttribute(Element, String, int) | Sets an integer attribute on the given element's style.
setOptionText(Element, String, int) | Sets the option text of the given select object.
setStyleAttribute(Element, String, String) | Sets an attribute on the given element's style.
sinkEvents(Element, int) | Sets the current set of events sunk by a given element.
toString(Element) | Returns a stringized version of the element.
windowGetClientHeight() | Gets the height of the browser window's client area excluding the scroll bar.
windowGetClientWidth() | Gets the width of the browser window's client area excluding the vertical scroll bar.

## Method Detail

### addEventPreview

public static void addEventPreview(EventPreview preview)
Adds an event preview to the preview stack. As long as this preview remains on the top of the stack, it will receive all events before they are fired to their listeners. Note that the event preview will receive all events, including those received due to bubbling, whereas normal event handlers only receive explicitly sunk events.

#### Parameters

preview
  the event preview to be added to the stack.

### appendChild

public static void appendChild(Element parent, Element child)
Appends one element to another's list of children.

#### Parameters

parent
  the parent element
child
  its new child

### compare

public static boolean compare(Element elem1, Element elem2)
Compares two elements for equality (note that reference equality is not sufficient to determine equality among elements on most browsers).

#### Parameters

elem1
  the first element to be compared
elem2
  the second element to be compared

#### Return Value

`true` if they are in fact the same element

#### See Also

isOrHasChild(Element, Element)

### createAnchor

public static Element createAnchor()
Creates an HTML A element.

#### Return Value

the newly-created element

### createButton

public static Element createButton()
Creates an HTML BUTTON element.

#### Return Value

the newly-created element

### createCaption

public static Element createCaption()
Creates an HTML CAPTION element.

#### Return Value

the newly-created element

### createCol

public static Element createCol()
Creates an HTML COL element.

#### Return Value

the newly-created element

### createColGroup

public static Element createColGroup()
Creates an HTML COLGROUP element.

#### Return Value

the newly-created element

### createDiv

public static Element createDiv()
Creates an HTML DIV element.

#### Return Value

the newly-created element

### createElement

public static Element createElement(String tagName)
Creates an HTML element.

#### Parameters

tagName
  the HTML tag of the element to be created

#### Return Value

the newly-created element

### createFieldSet

public static Element createFieldSet()
Creates an HTML FIELDSET element.

#### Return Value

the newly-created element

### createForm

public static Element createForm()
Creates an HTML FORM element.

#### Return Value

the newly-created element

### createIFrame

public static Element createIFrame()
Creates an HTML IFRAME element.

#### Return Value

the newly-created element

### createImg

public static Element createImg()
Creates an HTML IMG element.

#### Return Value

the newly-created element

### createInputCheck

public static Element createInputCheck()
Creates an HTML INPUT type='CHECK' element.

#### Return Value

the newly-created element

### createInputPassword

public static Element createInputPassword()
Creates an HTML INPUT type='PASSWORD' element.

#### Return Value

the newly-created element

### createInputRadio

public static Element createInputRadio(String name)
Creates an HTML INPUT type='RADIO' element.

#### Parameters

name
  the name of the group with which this radio button will be associated

#### Return Value

the newly-created element

### createInputText

public static Element createInputText()
Creates an HTML INPUT type='TEXT' element.

#### Return Value

the newly-created element

### createLabel

public static Element createLabel()
Creates an HTML LABEL element.

#### Return Value

the newly-created element

### createLegend

public static Element createLegend()
Creates an HTML LEGEND element.

#### Return Value

the newly-created element

### createOptions

public static Element createOptions()
Creates an HTML OPTIONS element.

#### Return Value

the newly-created element

### createSelect

public static Element createSelect()
Creates a single-selection HTML SELECT element. Equivalent to

     createSelect(false)

#### Return Value

the newly-created element

### createSelect

public static Element createSelect(boolean multiple)
Creates an HTML SELECT element.

#### Parameters

multiple
  true if multiple selection of options is allowed

#### Return Value

the newly-created element

### createSpan

public static Element createSpan()
Creates an HTML SPAN element.

#### Return Value

the newly-created element

### createTable

public static Element createTable()
Creates an HTML TABLE element.

#### Return Value

the newly-created element

### createTBody

public static Element createTBody()
Creates an HTML TBODY element.

#### Return Value

the newly-created element

### createTD

public static Element createTD()
Creates an HTML TD element.

#### Return Value

the newly-created element

### createTextArea

public static Element createTextArea()
Creates an HTML TEXTAREA element.

#### Return Value

the newly-created element

### createTFoot

public static Element createTFoot()
Creates an HTML TFOOT element.

#### Return Value

the newly-created element

### createTH

public static Element createTH()
Creates an HTML TH element.

#### Return Value

the newly-created element

### createTHead

public static Element createTHead()
Creates an HTML THEAD element.

#### Return Value

the newly-created element

### createTR

public static Element createTR()
Creates an HTML TR element.

#### Return Value

the newly-created element

### eventCancelBubble

public static void eventCancelBubble(Event evt, boolean cancel)
Cancels bubbling for the given event. This will stop the event from being propagated to parent elements.

#### Parameters

evt
  the event on which to cancel bubbling
cancel
  `true` to cancel bubbling

### eventGetAltKey

public static boolean eventGetAltKey(Event evt)
Gets whether the ALT key was depressed when the given event occurred.

#### Parameters

evt
  the event to be tested

#### Return Value

`true` if ALT was depressed when the event occurred

### eventGetButton

public static int eventGetButton(Event evt)
Gets the mouse buttons that were depressed when the given event occurred.

#### Parameters

evt
  the event to be tested

#### Return Value

a bit-field, defined by Event.BUTTON_LEFT, Event.BUTTON_MIDDLE, and Event.BUTTON_RIGHT

### eventGetClientX

public static int eventGetClientX(Event evt)
Gets the mouse x-position within the browser window's client area.

#### Parameters

evt
  the event to be tested

#### Return Value

the mouse x-position

### eventGetClientY

public static int eventGetClientY(Event evt)
Gets the mouse y-position within the browser window's client area.

#### Parameters

evt
  the event to be tested

#### Return Value

the mouse y-position

### eventGetCtrlKey

public static boolean eventGetCtrlKey(Event evt)
Gets whether the CTRL key was depressed when the given event occurred.

#### Parameters

evt
  the event to be tested

#### Return Value

`true` if CTRL was depressed when the event occurred

### eventGetCurrentEvent

public static Event eventGetCurrentEvent()
Gets the current event that is being fired. The current event is only available within the lifetime of the onBrowserEvent function. Once the onBrowserEvent method returns, the current event is reset to null.

#### Return Value

the current event

### eventGetCurrentTarget

public static Element eventGetCurrentTarget(Event evt)
Gets the current target element of the given event. This is the element whose listener fired last, not the element which fired the event initially.

#### Parameters

evt
  the event

#### Return Value

the event's current target element

#### See Also

DOM.eventGetTarget(Event)

### eventGetFromElement

public static Element eventGetFromElement(Event evt)
Gets the element from which the mouse pointer was moved (only valid for Event.ONMOUSEOVER).

#### Parameters

evt
  the event to be tested

#### Return Value

the element from which the mouse pointer was moved

### eventGetKeyCode

public static int eventGetKeyCode(Event evt)
Gets the key code associated with this event.

For Event.ONKEYPRESS, this method returns the Unicode value of the character generated. For Event.ONKEYDOWN and Event.ONKEYUP, it returns the code associated with the physical key.

#### Parameters

evt
  the event to be tested

#### Return Value

the Unicode character or key code.

#### See Also

KeyboardListener

### eventGetMetaKey

public static boolean eventGetMetaKey(Event evt)
Gets whether the META key was depressed when the given event occurred.

#### Parameters

evt
  the event to be tested

#### Return Value

`true` if META was depressed when the event occurred

### eventGetMouseWheelVelocityY

public static int eventGetMouseWheelVelocityY(Event evt)
Gets the velocity of the mouse wheel associated with the event along the Y axis.

The velocity of the event is an artifical measurement for relative comparisons of wheel activity. It is affected by some non-browser factors, including choice of input hardware and mouse acceleration settings. The sign of the velocity measurement agrees with the screen coordinate system; negative values are towards the origin and positive values are away from the origin. Standard scrolling speed is approximately ten units per event.

#### Parameters

evt
  the event to be examined.

#### Return Value

The velocity of the mouse wheel.

### eventGetRepeat

public static boolean eventGetRepeat(Event evt)
Gets the key-repeat state of this event.

#### Parameters

evt
  the event to be tested

#### Return Value

`true` if this key event was an auto-repeat

### eventGetScreenX

public static int eventGetScreenX(Event evt)
Gets the mouse x-position on the user's display.

#### Parameters

evt
  the event to be tested

#### Return Value

the mouse x-position

### eventGetScreenY

public static int eventGetScreenY(Event evt)
Gets the mouse y-position on the user's display.

#### Parameters

evt
  the event to be tested

#### Return Value

the mouse y-position

### eventGetShiftKey

public static boolean eventGetShiftKey(Event evt)
Gets whether the shift key was depressed when the given event occurred.

#### Parameters

evt
  the event to be tested

#### Return Value

`true` if shift was depressed when the event occurred

### eventGetTarget

public static Element eventGetTarget(Event evt)
Returns the element that was the actual target of the given event.

#### Parameters

evt
  the event to be tested

#### Return Value

the target element

### eventGetToElement

public static Element eventGetToElement(Event evt)
Gets the element to which the mouse pointer was moved (only valid for Event.ONMOUSEOUT).

#### Parameters

evt
  the event to be tested

#### Return Value

the element to which the mouse pointer was moved

### eventGetType

public static int eventGetType(Event evt)
Gets the enumerated type of this event (as defined in Event).

#### Parameters

evt
  the event to be tested

#### Return Value

the event's enumerated type

### eventGetTypeString

public static String eventGetTypeString(Event evt)
Gets the type of the given event as a string.

#### Parameters

evt
  the event to be tested

#### Return Value

the event's type name

### eventPreventDefault

public static void eventPreventDefault(Event evt)
Prevents the browser from taking its default action for the given event.

#### Parameters

evt
  the event whose default action is to be prevented

### eventSetKeyCode

public static void eventSetKeyCode(Event evt, char key)
Sets the key code associated with the given keyboard event.

#### Parameters

evt
  the event whose key code is to be set
key
  the new key code

### eventToString

public static String eventToString(Event evt)
Returns a stringized version of the event. This string is for debugging purposes and will NOT be consistent on different browsers.

#### Parameters

evt
  the event to stringize

#### Return Value

a string form of the event

### getAbsoluteLeft

public static int getAbsoluteLeft(Element elem)
Gets an element's absolute left coordinate in the document's coordinate system.

#### Parameters

elem
  the element to be measured

#### Return Value

the element's absolute left coordinate

### getAbsoluteTop

public static int getAbsoluteTop(Element elem)
Gets an element's absolute top coordinate in the document's coordinate system.

#### Parameters

elem
  the element to be measured

#### Return Value

the element's absolute top coordinate

### getAttribute

public static String getAttribute(Element elem, String attr)
Gets any named attribute from an element, as a string.

#### Parameters

elem
  the element whose attribute is to be retrieved
attr
  the name of the attribute

#### Return Value

the attribute's value

### getBooleanAttribute

public static boolean getBooleanAttribute(Element elem, String attr)
Gets a boolean attribute on the given element.

#### Parameters

elem
  the element whose attribute is to be set
attr
  the name of the attribute to be set

#### Return Value

the attribute's value as a boolean

### getCaptureElement

public static Element getCaptureElement()
Gets the element that currently has mouse capture.

#### Return Value

a handle to the capture element, or `null` if none exists

### getChild

public static Element getChild(Element parent, int index)
Gets an element's n-th child element.

#### Parameters

parent
  the element whose child is to be retrieved
index
  the index of the child element

#### Return Value

the n-th child element

### getChildCount

public static int getChildCount(Element parent)
Gets the number of child elements present in a given parent element.

#### Parameters

parent
  the element whose children are to be counted

#### Return Value

the number of children

### getChildIndex

public static int getChildIndex(Element parent, Element child)
Gets the index of a given child element within its parent.

#### Parameters

parent
  the parent element
child
  the child element

#### Return Value

the child's index within its parent, or `-1` if it is not a child of the given parent

### getElementAttribute

public static String getElementAttribute(Element elem, String attr)
Gets the named attribute from the element.

#### Parameters

elem
  the element whose property is to be retrieved
attr
  the name of the attribute

#### Return Value

the value of the attribute

### getElementById

public static Element getElementById(String id)
Gets the element associated with the given unique id within the entire document.

#### Parameters

id
  the id whose associated element is to be retrieved

#### Return Value

the associated element, or `null` if none is found

### getElementProperty

public static String getElementProperty(Element elem, String prop)
Gets any named property from an element, as a string.

#### Parameters

elem
  the element whose property is to be retrieved
prop
  the name of the property

#### Return Value

the property's value

### getElementPropertyBoolean

public static boolean getElementPropertyBoolean(Element elem, String prop)
Gets any named property from an element, as a boolean.

#### Parameters

elem
  the element whose property is to be retrieved
prop
  the name of the property

#### Return Value

the property's value as a boolean

### getElementPropertyInt

public static int getElementPropertyInt(Element elem, String prop)
Gets any named property from an element, as an int.

#### Parameters

elem
  the element whose property is to be retrieved
prop
  the name of the property

#### Return Value

the property's value as an int

### getEventsSunk

public static int getEventsSunk(Element elem)
Gets the current set of events sunk by a given element.

#### Parameters

elem
  the element whose events are to be retrieved

#### Return Value

a bitfield describing the events sunk on this element (its possible values are described in Event)

### getFirstChild

public static Element getFirstChild(Element elem)
Gets the first child element of the given element.

#### Parameters

elem
  the element whose child is to be retrieved

#### Return Value

the child element

### getImgSrc

public static String getImgSrc(Element img)
Gets the src attribute of an img element. This method is paired with setImgSrc(Element, String) so that it always returns the correct url.

#### Parameters

img
  a non-null img whose src attribute is to be read.

#### Return Value

the src url of the img

### getInnerHTML

public static String getInnerHTML(Element elem)
Gets an HTML representation of an element's children.

#### Parameters

elem
  the element whose HTML is to be retrieved

#### Return Value

the HTML representation of the element's children

### getInnerText

public static String getInnerText(Element elem)
Gets the text contained within an element. If the element has child elements, only the text between them will be retrieved.

#### Parameters

elem
  the element whose inner text is to be retrieved

#### Return Value

the text inside this element

### getIntAttribute

public static int getIntAttribute(Element elem, String attr)
Gets an integer attribute on a given element.

#### Parameters

elem
  the element whose attribute is to be retrieved
attr
  the name of the attribute to be retrieved

#### Return Value

the attribute's value as an integer

### getIntStyleAttribute

public static int getIntStyleAttribute(Element elem, String attr)
Gets an integer attribute on a given element's style.

#### Parameters

elem
  the element whose style attribute is to be retrieved
attr
  the name of the attribute to be retrieved

#### Return Value

the style attribute's value as an integer

### getNextSibling

public static Element getNextSibling(Element elem)
Gets an element's next sibling element.

#### Parameters

elem
  the element whose sibling is to be retrieved

#### Return Value

the sibling element

### getParent

public static Element getParent(Element elem)
Gets an element's parent element.

#### Parameters

elem
  the element whose parent is to be retrieved

#### Return Value

the parent element

### getStyleAttribute

public static String getStyleAttribute(Element elem, String attr)
Gets an attribute of the given element's style.

#### Parameters

elem
  the element whose style attribute is to be retrieved
attr
  the name of the style attribute to be retrieved

#### Return Value

the style attribute's value

### insertBefore

public static void insertBefore(Element parent, Element child, Element before)
Inserts an element as a child of the given parent element, before another child of that parent.

#### Parameters

parent
  the parent element
child
  the child element to add to `parent`
before
  an existing child element of `parent` before which `child` will be inserted

### insertChild

public static void insertChild(Element parent, Element child, int index)
Inserts an element as a child of the given parent element.

#### Parameters

parent
  the parent element
child
  the child element to add to `parent`
index
  the index before which the child will be inserted (any value greater than the number of existing children will cause the child to be appended)

### insertListItem

public static void insertListItem(Element select, String item, String value, int index)
Creates an `<option>` element and inserts it as a child of the specified `<select>` element. If the index is less than zero, or greater than or equal to the length of the list, then the option element will be appended to the end of the list.

#### Parameters

select
  the `<select>` element
item
  the text of the new item; cannot be `null`
value
  the `value` attribute for the new `<option>`; cannot be `null`
index
  the index at which to insert the child

### isOrHasChild

public static boolean isOrHasChild(Element parent, Element child)
Determine whether one element is equal to, or the child of, another.

#### Parameters

parent
  the potential parent element
child
  the potential child element

#### Return Value

`true` if the relationship holds

#### See Also

compare(Element, Element)

### releaseCapture

public static void releaseCapture(Element elem)
Releases mouse capture on the given element. Calling this method has no effect if the element does not currently have mouse capture.

#### Parameters

elem
  the element to release capture

#### See Also

setCapture(Element)

### removeChild

public static void removeChild(Element parent, Element child)
Removes a child element from the given parent element.

#### Parameters

parent
  the parent element
child
  the child element to be removed

### removeElementAttribute

public static void removeElementAttribute(Element elem, String attr)
Removes the named attribute from the given element.

#### Parameters

elem
  the element whose attribute is to be removed
attr
  the name of the element to remove

### removeEventPreview

public static void removeEventPreview(EventPreview preview)
Removes an element from the preview stack. This element will no longer capture events, though any preview underneath it will begin to do so.

#### Parameters

preview
  the event preview to be removed from the stack

### scrollIntoView

public static void scrollIntoView(Element elem)
Scrolls the given element into view.

This method crawls up the DOM hierarchy, adjusting the scrollLeft and scrollTop properties of each scrollable element to ensure that the specified element is completely in view. It adjusts each scroll position by the minimum amount necessary.

#### Parameters

elem
  the element to be made visible

### setAttribute

public static void setAttribute(Element elem, String attr, String value)
Sets an attribute on the given element.

#### Parameters

elem
  the element whose attribute is to be set
attr
  the name of the attribute to be set
value
  the new attribute value

### setBooleanAttribute

public static void setBooleanAttribute(Element elem, String attr, boolean value)
Sets a boolean attribute on the given element.

#### Parameters

elem
  the element whose attribute is to be set
attr
  the name of the attribute to be set
value
  the attribute's new boolean value

### setCapture

public static void setCapture(Element elem)
Sets mouse-capture on the given element. This element will directly receive all mouse events until releaseCapture(Element) is called on it.

#### Parameters

elem
  the element on which to set mouse capture

### setElementAttribute

public static void setElementAttribute(Element elem, String attr, String value)
Sets an attribute on a given element.

#### Parameters

elem
  element whose attribute is to be set
attr
  the name of the attribute
value
  the value to which the attribute should be set

### setElementProperty

public static void setElementProperty(Element elem, String prop, String value)
Sets a property on the given element.

#### Parameters

elem
  the element whose property is to be set
prop
  the name of the property to be set
value
  the new property value

### setElementPropertyBoolean

public static void setElementPropertyBoolean(Element elem, String prop, boolean value)
Sets a boolean property on the given element.

#### Parameters

elem
  the element whose property is to be set
prop
  the name of the property to be set
value
  the new property value as a boolean

### setElementPropertyInt

public static void setElementPropertyInt(Element elem, String prop, int value)
Sets an int property on the given element.

#### Parameters

elem
  the element whose property is to be set
prop
  the name of the property to be set
value
  the new property value as an int

### setEventListener

public static void setEventListener(Element elem, EventListener listener)
Sets the EventListener to receive events for the given element. Only one such listener may exist for a single element.

#### Parameters

elem
  the element whose listener is to be set
listener
  the listener to receive events

### setImgSrc

public static void setImgSrc(Element img, String src)
Sets the src attribute of an img element. This method ensures that imgs only ever have their contents requested one single time from the server.

#### Parameters

img
  a non-null img whose src attribute will be set.
src
  a non-null url for the img

### setInnerHTML

public static void setInnerHTML(Element elem, String html)
Sets the HTML contained within an element.

#### Parameters

elem
  the element whose inner HTML is to be set
html
  the new html

### setInnerText

public static void setInnerText(Element elem, String text)
Sets the text contained within an element. If the element already has children, they will be destroyed.

#### Parameters

elem
  the element whose inner text is to be set
text
  the new text

### setIntAttribute

public static void setIntAttribute(Element elem, String attr, int value)
Sets an integer attribute on the given element.

#### Parameters

elem
  the element whose attribute is to be set
attr
  the name of the attribute to be set
value
  the attribute's new integer value

### setIntStyleAttribute

public static void setIntStyleAttribute(Element elem, String attr, int value)
Sets an integer attribute on the given element's style.

#### Parameters

elem
  the element whose style attribute is to be set
attr
  the name of the style attribute to be set
value
  the style attribute's new integer value

### setOptionText

public static void setOptionText(Element select, String text, int index)
Sets the option text of the given select object.

#### Parameters

select
  the select object whose option text is being set
text
  the text to set
index
  the index of the option whose text should be set

### setStyleAttribute

public static void setStyleAttribute(Element elem, String attr, String value)
Sets an attribute on the given element's style.

#### Parameters

elem
  the element whose style attribute is to be set
attr
  the name of the style attribute to be set
value
  the style attribute's new value

### sinkEvents

public static void sinkEvents(Element elem, int eventBits)
Sets the current set of events sunk by a given element. These events will be fired to the nearest EventListener specified on any of the element's parents.

#### Parameters

elem
  the element whose events are to be retrieved
eventBits
  a bitfield describing the events sunk on this element (its possible values are described in Event)

### toString

public static String toString(Element elem)
Returns a stringized version of the element. This string is for debugging purposes and will NOT be consistent on different browsers.

#### Parameters

elem
  the element to stringize

#### Return Value

a string form of the element

### windowGetClientHeight

public static int windowGetClientHeight()
Gets the height of the browser window's client area excluding the scroll bar.

#### Return Value

the window's client height

### windowGetClientWidth

public static int windowGetClientWidth()
Gets the width of the browser window's client area excluding the vertical scroll bar.

#### Return Value

the window's client width