net.xoetrope.html
Class XButton

java.lang.Object
  extended by net.xoetrope.html.XHtmlWidget
      extended by net.xoetrope.html.XButton
All Implemented Interfaces:
XAttributedComponent, XTextHolder, XValueHolder

public class XButton
extends XHtmlWidget
implements XTextHolder, XValueHolder, XAttributedComponent

A wrapper for the AWT Button class. In addition to wrapping the button this object can hold a value.

Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt


Field Summary
protected  netscape.javascript.JSObject obj
           
 
Fields inherited from class net.xoetrope.html.XHtmlWidget
currentProject, divElement, htmlDoc, imageElement, inputElement, labelElement, metaElement, olElement, selectElement, tableElement, textareaElement, ulElement
 
Constructor Summary
XButton(boolean isImage)
          Create a new button
XButton(org.w3c.dom.html.HTMLInputElement inputElement)
          Create a new XButton based on an existing HTML button element.
XButton(java.lang.String value, java.lang.String id)
          Create a new text button with a value and an id
XButton(java.lang.String src, java.lang.String id, java.lang.String alt)
          Create a new image button with a src, an id and an alt attribute
 
Method Summary
 void click()
          Simulate a click on the XButton.
 void deleteElement()
          Delete the current XButton.
 java.lang.String getAccessKey()
          Get the shortcut key to click on this XButton
 java.lang.String getAlign()
          Get the align attribute of the XButton.
 java.lang.String getAlternativeName()
          Get the alt attribute of the XButton.
 java.lang.String getAttribute(java.lang.String attribName)
          Get an attribute value
 java.lang.String getBackgroundColor()
          Get the background color of the XButton.
 java.lang.String getFontColor()
          Get the font color of the XButton.
 int getFontSize()
          Get the size of the XButton's text.
 org.w3c.dom.html.HTMLFormElement getForm()
          Get the form this XButton belongs to.
 org.w3c.dom.html.HTMLInputElement getHTMLElement()
          Get the HTML element at which refers the XButton
 java.lang.String getSize()
          Get the size of the XButton
 java.lang.String getText()
          Get teh button text/caption
 java.lang.String getType()
          Get the button type
 java.lang.Object getValue()
          Get teh button text/caption
 void insertAfter(java.lang.String element, java.lang.String id)
          Insert a new button after the current one
 void insertBefore(java.lang.String element, java.lang.String id)
          Insert a new button before the current one
 void setAccessKey(java.lang.String accessKey)
          Set a shortcut to click on this XButton
 void setAlign(java.lang.String align)
          Set the align attribute of the XButton
 void setAlternativeName(java.lang.String name)
          Set the alt attribute of the XButton.
 int setAttribute(java.lang.String attribName, java.lang.Object attribValue)
          Set one or more attributes of the component.
 void setBackgroundColor(java.lang.String hexColor)
          Set the background color of the XButton.
 void setEnabled(boolean enabled)
          Set the XButton enabled or disabled.
 void setFontColor(java.lang.String hexColor)
          Set the font color of the XButton.
 void setFontSize(int fontsize)
          Set the size of the XButton's text.
 void setSize(int width)
          Set the size of the XButton.
 void setText(java.lang.String s)
          Set the button text/caption
 void setValue(java.lang.Object obj)
          Set teh button text/caption
 void setVisible(boolean visible)
          Set the XButton visible or invisible.
 
Methods inherited from class net.xoetrope.html.XHtmlWidget
addEvent, setObject, setObject, setObject, setObject, setObject, setObject, setObject, setObject, setObject, setObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obj

protected netscape.javascript.JSObject obj
Constructor Detail

XButton

public XButton(boolean isImage)
Create a new button

Parameters:
isImage - true if the button is an image button, false otherwise

XButton

public XButton(java.lang.String value,
               java.lang.String id)
Create a new text button with a value and an id

Parameters:
value - the button value
id - the button id

XButton

public XButton(java.lang.String src,
               java.lang.String id,
               java.lang.String alt)
Create a new image button with a src, an id and an alt attribute

Parameters:
src - the image source
id - the button id
alt - the alternative text to display if the button can't load

XButton

public XButton(org.w3c.dom.html.HTMLInputElement inputElement)
Create a new XButton based on an existing HTML button element.

Parameters:
inputElement - the HTML input tag the XButton refers to
Method Detail

click

public void click()
Simulate a click on the XButton.


setText

public void setText(java.lang.String s)
Set the button text/caption

Specified by:
setText in interface XTextHolder
Specified by:
setText in interface XValueHolder
Parameters:
s - the new text

getText

public java.lang.String getText()
Get teh button text/caption

Specified by:
getText in interface XTextHolder
Specified by:
getText in interface XValueHolder
Returns:
the current text

setValue

public void setValue(java.lang.Object obj)
Set teh button text/caption

Specified by:
setValue in interface XValueHolder
Parameters:
s - the new text

getValue

public java.lang.Object getValue()
Get teh button text/caption

Specified by:
getValue in interface XValueHolder
Returns:
the current text

getType

public java.lang.String getType()
Get the button type

Returns:
the button type (button, submit, image)

setVisible

public void setVisible(boolean visible)
Set the XButton visible or invisible.

Parameters:
visible - true if visible, false otherwise

setEnabled

public void setEnabled(boolean enabled)
Set the XButton enabled or disabled.

Parameters:
enabled - true if enabled, false otherwise

insertAfter

public void insertAfter(java.lang.String element,
                        java.lang.String id)
Insert a new button after the current one

Parameters:
element - the displayed name of the button
id - the unique identifier of the button

insertBefore

public void insertBefore(java.lang.String element,
                         java.lang.String id)
Insert a new button before the current one

Parameters:
element - the displayed name of the button
id - the unique identifier of the button

deleteElement

public void deleteElement()
Delete the current XButton.


setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component.

Specified by:
setAttribute in interface XAttributedComponent
Parameters:
attribName - the name of the attribute
attribValue - the value of the attribute
Returns:
0 for success, non zero for failure or to require some further action

getAttribute

public java.lang.String getAttribute(java.lang.String attribName)
Get an attribute value

Parameters:
attribName - the attribute which value is requested
Returns:
the value of this attribute

setAccessKey

public void setAccessKey(java.lang.String accessKey)
Set a shortcut to click on this XButton

Parameters:
accessKey - the key used as a shortcut

getAccessKey

public java.lang.String getAccessKey()
Get the shortcut key to click on this XButton

Returns:
the key used as a shortcut

setAlign

public void setAlign(java.lang.String align)
Set the align attribute of the XButton

Parameters:
align - the alignment of the XButton (left, right, center, justified)

getAlign

public java.lang.String getAlign()
Get the align attribute of the XButton.

Returns:
the alignment of this XButton

setAlternativeName

public void setAlternativeName(java.lang.String name)
Set the alt attribute of the XButton.

Parameters:
name - the alternative name to be displayed

getAlternativeName

public java.lang.String getAlternativeName()
Get the alt attribute of the XButton.

Returns:
the alternative name for this XButton

getForm

public org.w3c.dom.html.HTMLFormElement getForm()
Get the form this XButton belongs to.

Returns:
the HTML Form element

setSize

public void setSize(int width)
Set the size of the XButton.

Parameters:
width - the width of the button

getSize

public java.lang.String getSize()
Get the size of the XButton

Returns:
the width of the button

getFontSize

public int getFontSize()
Get the size of the XButton's text.

Returns:
the int value of the font size

setFontSize

public void setFontSize(int fontsize)
Set the size of the XButton's text.

Parameters:
fontsize - the int value of the font size

getBackgroundColor

public java.lang.String getBackgroundColor()
Get the background color of the XButton.

Returns:
the hexadecimal value of the background color

setBackgroundColor

public void setBackgroundColor(java.lang.String hexColor)
Set the background color of the XButton.

Parameters:
hexColor - the hexadecimal value of the background color

getFontColor

public java.lang.String getFontColor()
Get the font color of the XButton.

Returns:
the hexadecimal value of the font color

setFontColor

public void setFontColor(java.lang.String hexColor)
Set the font color of the XButton.

Parameters:
hexColor - the hexadecimal value of the font color

getHTMLElement

public org.w3c.dom.html.HTMLInputElement getHTMLElement()
Get the HTML element at which refers the XButton

Returns:
the HTML element.