PasswordField with additional features.
This component allows for the display of icons or nodes on both the left and right sides of the password field. It also provides the capability to toggle the visibility of the password, allowing the password to be shown as plain text or masked with a customizable echo character. The echo character and visibility can be styled and controlled through CSS or programmatically.
Key features:
EnhancedPasswordField passwordField = new EnhancedPasswordField();
passwordField.setLeft(new ImageView(new Image("path/to/icon.png")));
passwordField.setRight(new Button("Show", e -> passwordField.setShowPassword(!passwordField.isShowPassword())));
PasswordField
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final char | |
| private static final boolean | |
| private static final String | |
| private ObjectProperty | |
| private final ObjectProperty | left
Hides javafx. |
| private final Logger | |
| private final ObjectProperty | right
Hides javafx. |
| private static final PseudoClass | |
| private BooleanProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final ObjectProperty | |
| public static List | getClassCssMetaData()
Hides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final Character | |
| public final Character | Returns: the character to be used as an echo character, orDEFAULT_ECHO_CHAR if the
property is null or an exception occursRetrieves the echo character property value safely. |
| public final Node | |
| public final Node | |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| public final boolean | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final BooleanProperty | Returns: the show password propertyIndicates whether the password is currently shown in plain text. |
| DEFAULT_ECHO_CHAR | back to summary |
|---|---|
| public static final char DEFAULT_ECHO_CHAR | |
| DEFAULT_SHOW_PASSWORD | back to summary |
|---|---|
| private static final boolean DEFAULT_SHOW_PASSWORD | |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| echoCharProperty | back to summary |
|---|---|
| private ObjectProperty<Character> echoCharProperty | |
| left | back to summary |
|---|---|
| private final ObjectProperty<Node> left Hides javafx. The node to be shown on the left side of the password field. returns the node to be shown on the left side of the password field. | |
| LOG | back to summary |
|---|---|
| private final Logger LOG | |
| right | back to summary |
|---|---|
| private final ObjectProperty<Node> right Hides javafx. The node to be shown on the right side of the password field. returns the node to be shown on the right side of the password field. | |
| SHOWING_PASSWORD_PSEUDO_CLASS | back to summary |
|---|---|
| private static final PseudoClass SHOWING_PASSWORD_PSEUDO_CLASS | |
| showPassword | back to summary |
|---|---|
| private BooleanProperty showPassword | |
| EnhancedPasswordField | back to summary |
|---|---|
| public EnhancedPasswordField() | |
| EnhancedPasswordField | back to summary |
|---|---|
| public EnhancedPasswordField(String text) | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. 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
| |
| echoCharProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Doc from javafx. Gets the | |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getEchoChar | back to summary |
|---|---|
| public final Character getEchoChar() | |
| getEchoCharSafe | back to summary |
|---|---|
| public final Character getEchoCharSafe() Retrieves the echo character property value safely. This method provides a safe way to access the echo character. It ensures that if the property is not set or an exception occurs during retrieval, a default echo character will be returned. This approach prevents the application from crashing due to unhandled exceptions and ensures that there is always a valid character returned.
If the property value is
| |
| getLeft | back to summary |
|---|---|
| public final Node getLeft() | |
| getRight | back to summary |
|---|---|
| public final Node getRight() | |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides javafx. Doc from javafx. 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.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| isShowPassword | back to summary |
|---|---|
| public final boolean isShowPassword() | |
| leftProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| rightProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| setEchoChar | back to summary |
|---|---|
| public final void setEchoChar(Character echoChar) | |
| setLeft | back to summary |
|---|---|
| public final void setLeft(Node left) | |
| setRight | back to summary |
|---|---|
| public final void setRight(Node right) | |
| setShowPassword | back to summary |
|---|---|
| public final void setShowPassword(boolean showPassword) | |
| showPasswordProperty | back to summary |
|---|---|
| public final BooleanProperty showPasswordProperty() Indicates whether the password is currently shown in plain text.
This property can be used to toggle the visibility of the password. If set to
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| private |
| ECHO_CHAR | back to summary |
|---|---|
| private static final CssMetaData<EnhancedPasswordField, Character> ECHO_CHAR | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |