TextField - relu91/nifty-gui GitHub Wiki

Table of Contents

TextField

Description

The TextField control allows input of text. The creation is dynamically possible from Java with the TextFieldBuilder class as well as from XML using Niftys Standard <control></control> Tag. The length of the input field can be restricted and the actual input can be hidden with an optional password char if necessary.

Java API

TextField

Standard Parameters

The following table describes all TextField parameters.

Name Datatype Default Description
text String "" The initial text that the TextField contains.
maxLength Integer (not set) The maximum length of characters that this TextField can contain. If not set or if this value is -1 then no restriction is applied.
passwordChar Character (not set) If set then each character of the TextField will be replaced by the given char. If you use '*' for this you can get a typical password input field.

EventBus Notification

The TextField control supports EventBus notification for any changes applied to the text. Whenever the text content of the TextField changes a TextFieldChangedEvent is published using the id of the TextField as the Topic for the Event.

TextFieldChangedEvent

Java Builder Example

// Using the builder pattern
control(new TextFieldBuilder("passwordCharTextField", "*") {{ // init with the text "*"
  maxLength(1); // force only a single character input
  width("20px");
}});

XML Example

<!-- simple password textfield example. please note: event notification requires an id -->
<control name="textfield" maxLength="20" passwordChar="*" />

Back to Nifty Standard Controls (Nifty 1.3)

⚠️ **GitHub.com Fallback** ⚠️