Summary
A label is a view which displays a single text value. The text can be aligned and text color can be set. A label is created from the root view using createLabel. See the View class reference.
void setText(text)
String getText()
void setTextAlignmment(alignment)
void setTextColor(red,green,blue,alpha)
void setFont(font);
Please note that all the Label methods are common with Button, TextField and TextView classes
Example
root = new View("ipad-portrait");
root.setBackgroundColor(0.1,0.1,0.5,1);
label = root.createLabel(400,200);
label.setBackgroundColor(0.5,0.1,0.1,1);
label.setTextColor(1,1,1,1);
label.setText("Hello, World!");
label.setTextAlignment("center");
text = label.getText();
document.writeln(text);
document.wait();
setText
Sets the text of a label view
void setText(text)
Parameters
text - string text value
Return Value
none
Notes
Text set on a label can be retrieved using the getText() method on the label object.
getText
Return text string of label, button, text field, or text view
String getText()
Parameters
none
Return Value
Text label
Notes
This method applies to Label, TextField, TextView, and Button objects.
setTextAlignment
Controls the alignment of text within a label, text field, or text view
void setTextAlignment(alignment)
Parameters
alignment - string, one of the following: "left", "right", "center"
Return Value
none
Notes
This method applies to Label, TextField, and TextView objects.
setTextColor
Changes the text color of a label, button, text field, or text view object.
setTextColor(red,green,blue,alpha)
Parameters
red - sets the red color component value between 0 and 1
green - sets the green color component value between 0 and 1
blue - sets the blue color component value between 0 and 1
alpha - sets the alpha component value between 0 and 1 (0 transparent)
Return Value
none
Notes
This method applies to Label, TextField, TextView, and Button objects.
setFont
Changes the text font of a label, button, text field, or text view object.
setFont(font)
Parameters
font - font object
Return Value
none
Notes
This method applies to Label, TextField, TextView, and Button objects. The font object must be created using the Font() constructor function.