# WRTKit Label Class

## Description

The Label class implements a control that displays a simple piece of text. A label is used in situations where there's a caption-value pair that needs to be displayed, e.g. "Name: John Smith".

Figure 1. Label control

## Inherits from

Control

Parent topic: WRTKit API Reference

## Constructor

### Syntax

    [Label] new Label(String id, String caption, String text)

### Description

Creates a new instance of the Label class.

### Arguments

- id

  Unique identifier for the control. Can be retrieved using the id property defined in the UIElement class that this control inherits from. Useful for example to identify the source of an event in event callback functions or to apply a CSS rule to only this particular control. The identifier can be null, in which case no id will be set for the control.

- caption

  The caption text for the control. A null caption can be used to hide the caption area. This is not recommended for a label since without a caption the value of the label doesn't make sense to the user. The value is an XHTML string.

- text

  The content for the label. If the argument is omitted or null then the content area will be empty. The value is an XHTML string.

### Return value

A new instance of the Label class.

## getText()

### Syntax

    [String] Label.getText(void)

### Description

Retrieves the current text value of the label. The value is an XHTML string.

### Arguments

This method does not take any arguments.

### Return value

The current text value of the label.

## setText()

### Syntax

    [void] Label.setText(String text)

### Description

Sets the text value of the label. The value is an XHTML string.

### Arguments

- text

  The text to be displayed as the value of the label. Passing null results in no text.

### Return value

This method does not return a value.