Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class EmailField

extends Control
Class Inheritance
Imports
com.dlsc.gemsfx.skins.EmailFieldSkin, javafx.beans.binding.Bindings, javafx.beans.property.BooleanProperty, .ListProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .SimpleBooleanProperty, .SimpleListProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .ObservableList, javafx.css.CssMetaData, .PseudoClass, .SimpleStyleableBooleanProperty, .Styleable, .StyleableBooleanProperty, .StyleableProperty, javafx.css.converter.BooleanConverter, javafx.scene.control.Control, .ListCell, .ListView, .Skin, javafx.util.Callback, org.apache.commons.lang3.StringUtils, org.apache.commons.validator.routines.EmailValidator, org.controlsfx.control.textfield.CustomTextField, java.util.ArrayList, .Collections, .List, .Objects, .StringTokenizer

EmailField is a custom control for inputting and validating email addresses. It provides the following functionalities:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private BooleanProperty
private static final boolean
private static final boolean
private static final boolean
private final ListProperty<String>
private ObjectProperty<Callback<ListView<String>, ListCell<String>>>
private final CustomTextField
private final StringProperty
private static final EmailValidator
private static final PseudoClass
private final StringProperty
private final ListProperty<String>
private final StringProperty
private final BooleanProperty
private final StyleableBooleanProperty
private final StyleableBooleanProperty
private final BooleanProperty
private final ReadOnlyBooleanWrapper
private static final PseudoClass

Constructor Summary

AccessConstructor and Description
public
EmailField()

Constructs a new email field.

public
EmailField(String emailAddress)

Constructs a new email field with the given initial email address.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty

Returns:

The BooleanProperty representing the state of auto domain completion.
autoDomainCompletionEnabledProperty
()

Property for enabling or disabling the auto-completion of email domains.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObjectProperty<Callback<ListView<String>, ListCell<String>>>

Returns:

The ObjectProperty representing the domain list cell factory.
domainListCellFactoryProperty
()

Returns the property for the domain list cell factory.

public final ListProperty<String>

Returns:

list of known domains
domainListProperty
()

Stores a list of known domains that are often used for email addreses, e.g. gmail.com or outlook.com.

public final StringProperty

Returns:

the entered email address
emailAddressProperty
()

Stores a valid email address.

public static List<CssMetaData<? extends Styleable, ?>>
getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

protected List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final ObservableList<String>
public final Callback<ListView<String>, ListCell<String>>
public final CustomTextField

Returns:

the editor text field
getEditor
()

Returns the text field used for editing purposes.

public final String
public final String

Returns:

Tooltip text for an invalid email address.
getInvalidText
()

Retrieves the tooltip text displayed when the email address validation fails and the user hovers over the invalid icon.

public final ObservableList<String>
public final String
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final StringProperty

Returns:

The StringProperty for the tooltip text of an invalid email address.
invalidTextProperty
()

Property for changing the tooltip text, which is displayed when hovering over the invalid icon after email address validation fails.

public final boolean
public final boolean
public final boolean

Returns:

The mail icon visibility
isShowMailIcon
()

Returns true if the mail icon is visible, otherwise false.

public final boolean

Returns:

The validation icon visibility
isShowValidationIcon
()

Returns true if the validation icon is visible, otherwise false.

public final boolean
public final boolean
public final ListProperty<String>

Returns:

the list of valid email addresses
multipleEmailAddressesProperty
()

Stores the list of valid email addresses entered by the user.

public final StringProperty

Returns:

the prompt text
promptTextProperty
()

The prompt text to display by the editor.

public final BooleanProperty

Returns:

the flag used to determine if the field is required
requiredProperty
()

A flag signalling that this is a required field.

public final void
setAutoDomainCompletionEnabled(boolean autoDomainCompletionEnabled)

public final void
public final void
public final void
setEmailAddress(String emailAddress)

public final void
setInvalidText(String
The tooltip text to set for an invalid email address.
invalidText
)

Sets the tooltip text that appears when the user hovers over the icon indicating the email address is invalid.

public final void
public final void
setPromptText(String promptText)

public final void
setRequired(boolean required)

public final void
setShowMailIcon(boolean
true if the mail icon should be visible, otherwise false
showMailIcon
)

Sets the visibility of the mail icon.

public final void
setShowValidationIcon(boolean
true if the validation icon should be visible, otherwise false
showValidationIcon
)

Sets the visibility of the validation icon.

public final void
setSupportingMultipleAddresses(boolean supportingMultipleAddresses)

public final BooleanProperty
showMailIconProperty()

Property for handling the mail icon visibility.

public final BooleanProperty
showValidationIconProperty()

Property for handling the validation icon visibility.

public final BooleanProperty

Returns:

a flag used for controlling input behaviour (single vs. multiple email addresses)
supportingMultipleAddressesProperty
()

A control flag used to determine if the user should be able to enter more than one email address into the field.

private void
public final ReadOnlyBooleanProperty

Returns:

a boolean property signalling validity
validProperty
()

A boolean flag used to indicate whether the field is currently in a valid state.

Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinPropertytooltipProperty

Field Detail

autoDomainCompletionEnabledback to summary
private BooleanProperty autoDomainCompletionEnabled
DEFAULT_AUTO_DOMAIN_COMPLETION_ENABLEDback to summary
private static final boolean DEFAULT_AUTO_DOMAIN_COMPLETION_ENABLED
DEFAULT_SHOW_MAIL_ICONback to summary
private static final boolean DEFAULT_SHOW_MAIL_ICON
DEFAULT_SHOW_VALIDATION_ICONback to summary
private static final boolean DEFAULT_SHOW_VALIDATION_ICON
domainListback to summary
private final ListProperty<String> domainList
domainListCellFactoryback to summary
private ObjectProperty<Callback<ListView<String>, ListCell<String>>> domainListCellFactory
editorback to summary
private final CustomTextField editor
emailAddressback to summary
private final StringProperty emailAddress
emailValidatorback to summary
private static final EmailValidator emailValidator
INVALID_PSEUDO_CLASSback to summary
private static final PseudoClass INVALID_PSEUDO_CLASS
invalidTextback to summary
private final StringProperty invalidText
multipleEmailAddressesback to summary
private final ListProperty<String> multipleEmailAddresses
promptTextback to summary
private final StringProperty promptText
requiredback to summary
private final BooleanProperty required
showMailIconback to summary
private final StyleableBooleanProperty showMailIcon
showValidationIconback to summary
private final StyleableBooleanProperty showValidationIcon
supportingMultipleAddressesback to summary
private final BooleanProperty supportingMultipleAddresses
validback to summary
private final ReadOnlyBooleanWrapper valid
VALID_PSEUDO_CLASSback to summary
private static final PseudoClass VALID_PSEUDO_CLASS

Constructor Detail

EmailFieldback to summary
public EmailField()

Constructs a new email field.

EmailFieldback to summary
public EmailField(String emailAddress)

Constructs a new email field with the given initial email address.

Method Detail

autoDomainCompletionEnabledPropertyback to summary
public final BooleanProperty autoDomainCompletionEnabledProperty()

Property for enabling or disabling the auto-completion of email domains.

Returns:BooleanProperty

The BooleanProperty representing the state of auto domain completion.

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
domainListCellFactoryPropertyback to summary
public final ObjectProperty<Callback<ListView<String>, ListCell<String>>> domainListCellFactoryProperty()

Returns the property for the domain list cell factory. This property can be used to customize the rendering of the domain suggestions in the ListView.

Returns:ObjectProperty<Callback<ListView<String>, ListCell<String>>>

The ObjectProperty representing the domain list cell factory.

domainListPropertyback to summary
public final ListProperty<String> domainListProperty()

Stores a list of known domains that are often used for email addreses, e.g. gmail.com or outlook.com.

Returns:ListProperty<String>

list of known domains

emailAddressPropertyback to summary
public final StringProperty emailAddressProperty()

Stores a valid email address. This property will only be non-null if the user has entered a valid email address. This property is only used if the field is configured for entering a single address. If the field is configured for multiple email addresses then this field will be unused and the address list can be found in multipleEmailAddressesProperty().

Returns:StringProperty

the entered email address

getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Doc from javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

getControlCssMetaDataback to summary
protected List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Annotations
@Override
getDomainListback to summary
public final ObservableList<String> getDomainList()
getDomainListCellFactoryback to summary
public final Callback<ListView<String>, ListCell<String>> getDomainListCellFactory()
getEditorback to summary
public final CustomTextField getEditor()

Returns the text field used for editing purposes.

Returns:CustomTextField

the editor text field

getEmailAddressback to summary
public final String getEmailAddress()
getInvalidTextback to summary
public final String getInvalidText()

Retrieves the tooltip text displayed when the email address validation fails and the user hovers over the invalid icon.

Returns:String

Tooltip text for an invalid email address.

getMultipleEmailAddressesback to summary
public final ObservableList<String> getMultipleEmailAddresses()
getPromptTextback to summary
public final String getPromptText()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
invalidTextPropertyback to summary
public final StringProperty invalidTextProperty()

Property for changing the tooltip text, which is displayed when hovering over the invalid icon after email address validation fails.

Returns:StringProperty

The StringProperty for the tooltip text of an invalid email address.

isAutoDomainCompletionEnabledback to summary
public final boolean isAutoDomainCompletionEnabled()
isRequiredback to summary
public final boolean isRequired()
isShowMailIconback to summary
public final boolean isShowMailIcon()

Returns true if the mail icon is visible, otherwise false.

Returns:boolean

The mail icon visibility

isShowValidationIconback to summary
public final boolean isShowValidationIcon()

Returns true if the validation icon is visible, otherwise false.

Returns:boolean

The validation icon visibility

isSupportingMultipleAddressesback to summary
public final boolean isSupportingMultipleAddresses()
isValidback to summary
public final boolean isValid()
multipleEmailAddressesPropertyback to summary
public final ListProperty<String> multipleEmailAddressesProperty()

Stores the list of valid email addresses entered by the user. This list is only used when the field supports entering multiple addresses.

Returns:ListProperty<String>

the list of valid email addresses

See Also
supportingMultipleAddressesProperty()
promptTextPropertyback to summary
public final StringProperty promptTextProperty()

The prompt text to display by the editor.

Returns:StringProperty

the prompt text

requiredPropertyback to summary
public final BooleanProperty requiredProperty()

A flag signalling that this is a required field. This flag will be taken into account when updating the state of the validProperty().

Returns:BooleanProperty

the flag used to determine if the field is required

setAutoDomainCompletionEnabledback to summary
public final void setAutoDomainCompletionEnabled(boolean autoDomainCompletionEnabled)
setDomainListback to summary
public final void setDomainList(ObservableList<String> domainList)
setDomainListCellFactoryback to summary
public final void setDomainListCellFactory(Callback<ListView<String>, ListCell<String>> cellFactory)
setEmailAddressback to summary
public final void setEmailAddress(String emailAddress)
setInvalidTextback to summary
public final void setInvalidText(String invalidText)

Sets the tooltip text that appears when the user hovers over the icon indicating the email address is invalid.

Parameters
invalidText:String

The tooltip text to set for an invalid email address.

setMultipleEmailAddressesback to summary
public final void setMultipleEmailAddresses(ObservableList<String> multipleEmailAddresses)
setPromptTextback to summary
public final void setPromptText(String promptText)
setRequiredback to summary
public final void setRequired(boolean required)
setShowMailIconback to summary
public final void setShowMailIcon(boolean showMailIcon)

Sets the visibility of the mail icon.

Parameters
showMailIcon:boolean

true if the mail icon should be visible, otherwise false

setShowValidationIconback to summary
public final void setShowValidationIcon(boolean showValidationIcon)

Sets the visibility of the validation icon.

Parameters
showValidationIcon:boolean

true if the validation icon should be visible, otherwise false

setSupportingMultipleAddressesback to summary
public final void setSupportingMultipleAddresses(boolean supportingMultipleAddresses)
showMailIconPropertyback to summary
public final BooleanProperty showMailIconProperty()

Property for handling the mail icon visibility.

showValidationIconPropertyback to summary
public final BooleanProperty showValidationIconProperty()

Property for handling the validation icon visibility.

supportingMultipleAddressesPropertyback to summary
public final BooleanProperty supportingMultipleAddressesProperty()

A control flag used to determine if the user should be able to enter more than one email address into the field.

Returns:BooleanProperty

a flag used for controlling input behaviour (single vs. multiple email addresses)

updateValidPseudoClassback to summary
private void updateValidPseudoClass(Boolean isValid)
validPropertyback to summary
public final ReadOnlyBooleanProperty validProperty()

A boolean flag used to indicate whether the field is currently in a valid state. The field is in a valid state when the entered email addresses are all structurally valid (obviously this does not mean that they do exist, only that they have the proper format).

Returns:ReadOnlyBooleanProperty

a boolean property signalling validity

com.dlsc.gemsfx back to summary

private Class EmailField.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<EmailField, Boolean>
private static final CssMetaData<EmailField, Boolean>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SHOW_MAIL_ICONback to summary
private static final CssMetaData<EmailField, Boolean> SHOW_MAIL_ICON
SHOW_VALIDATION_ICONback to summary
private static final CssMetaData<EmailField, Boolean> SHOW_VALIDATION_ICON
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()