net.xoetrope.html
Class XLabel

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

public class XLabel
extends XHtmlWidget
implements XTextHolder, XAttributedComponent

Draws text. The text may be wrapped over multiple lines. Double buffering is switched off by default.

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


Field Summary
protected  netscape.javascript.JSObject obj
           
protected  XTextRenderer renderer
          The renderer that will draw the content
protected  java.lang.String text
          The content of the label
 
Fields inherited from class net.xoetrope.html.XHtmlWidget
currentProject, divElement, htmlDoc, imageElement, inputElement, labelElement, metaElement, olElement, selectElement, tableElement, textareaElement, ulElement
 
Constructor Summary
XLabel()
          Create a new XLabel component.
XLabel(org.w3c.dom.html.HTMLLabelElement labelElement)
          Create a new XLabel based on an existing HTML label element.
XLabel(java.lang.String txt, java.lang.String id)
          Create a new XLabel component with a specific value and id.
 
Method Summary
 int getAlignment()
          Get the text alignment
 java.lang.String getBackgroundColor()
          Get the background color of the XLabel.
 java.lang.String getFontColor()
          Get the font color of the XLabel.
 int getFontSize()
          Get the size of the XLabel's text.
 org.w3c.dom.html.HTMLFormElement getForm()
          Get the form this XLabel belongs to.
 org.w3c.dom.html.HTMLLabelElement getHTMLElement()
          Get the HTML element at which refers the XLabel
 java.lang.String getHtmlFor()
          Get the element this XLabel depends on.
 java.lang.String getText()
          Get the text.
 boolean isVisible()
          Method used to know if the XLabel is visible or hidden on the HTML page.
 void setAlignment(int align)
          Set the alignment of the text.
 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 XLabel.
 void setBold(boolean bold)
          Put the XLabels's text in bold.
 void setFontColor(java.lang.String hexColor)
          Set the font color of the XLabel.
 void setFontSize(int fontsize)
          Set the size of the XLabel's text.
 void setHtmlFor(java.lang.String htmlFor)
          Set the element this XLabel depends on.
 void setText(java.lang.String str)
          Set the text content of the XLabel.
 void setVisible(boolean visible)
          Set the XLabel 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

text

protected java.lang.String text
The content of the label


renderer

protected XTextRenderer renderer
The renderer that will draw the content

Constructor Detail

XLabel

public XLabel()
Create a new XLabel component.


XLabel

public XLabel(java.lang.String txt,
              java.lang.String id)
Create a new XLabel component with a specific value and id.

Parameters:
txt - the text of this XLabel
id - the id at which the user has to refer to act on this component

XLabel

public XLabel(org.w3c.dom.html.HTMLLabelElement labelElement)
Create a new XLabel based on an existing HTML label element.

Parameters:
labelElement - the HTML label tag the XLabel refers to
Method Detail

setText

public void setText(java.lang.String str)
Set the text content of the XLabel.

Specified by:
setText in interface XTextHolder
Parameters:
str - the new text value

getText

public java.lang.String getText()
Get the text.

Specified by:
getText in interface XTextHolder
Returns:
the label text

getAlignment

public int getAlignment()
Get the text alignment

Returns:
the alignment flag
  • XTextRenderer.LEFT - left align the text
  • XTextRenderer.RIGHT - right align the text
  • XTextRenderer.CENTER - center the text

setAlignment

public void setAlignment(int align)
Set the alignment of the text.

Parameters:
align - 1 to right align the text, 0 for left alignment and 2 for centered text

setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component. Attributes include
  1. align (left|right|center ) or
  2. alignment (left|right|center )

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

setHtmlFor

public void setHtmlFor(java.lang.String htmlFor)
Set the element this XLabel depends on.

Parameters:
htmlFor - the id of this HTML element

getHtmlFor

public java.lang.String getHtmlFor()
Get the element this XLabel depends on.

Returns:
the id of this HTML element

getForm

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

Returns:
the HTML Form element

getFontSize

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

Returns:
the int value of the font size

setFontSize

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

Parameters:
fontsize - the int value of the font size

getBackgroundColor

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

Returns:
the hexadecimal value of the background color

setBackgroundColor

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

Parameters:
hexColor - the hexadecimal value of the background color

getFontColor

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

Returns:
the hexadecimal value of the font color

setFontColor

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

Parameters:
hexColor - the hexadecimal value of the font color

setVisible

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

Parameters:
visible - true if visible, false otherwise

isVisible

public boolean isVisible()
Method used to know if the XLabel is visible or hidden on the HTML page.

Returns:
true if the XLabel is visible, false otherwise

setBold

public void setBold(boolean bold)
Put the XLabels's text in bold.

Parameters:
bold - true to put the text in bold, false otherwise

getHTMLElement

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

Returns:
the HTML element.