Class SJPasswordField
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.textfield.PasswordField, String>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.textfield.PasswordField, String>
com.vaadin.flow.component.textfield.TextFieldBase<com.vaadin.flow.component.textfield.PasswordField, String>
com.vaadin.flow.component.textfield.PasswordField
com.vaadin.swingbridge.surrogates.SJPasswordField
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.textfield.PasswordField>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.textfield.PasswordField>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.textfield.PasswordField>, com.vaadin.flow.component.HasAriaDescription, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.textfield.PasswordField, String>, String>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.textfield.PasswordField, String>, String>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.shared.HasAllowedCharPattern, com.vaadin.flow.component.shared.HasClearButton, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.textfield.TextFieldVariant>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.textfield.PasswordField, String>, String>, com.vaadin.flow.component.textfield.HasAutocapitalize, com.vaadin.flow.component.textfield.HasAutocomplete, com.vaadin.flow.component.textfield.HasAutocorrect, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.data.value.HasValueChangeMode, ComponentMixin, ContainerMixin, EnterClaims.Claimant, JComponentMixin, JTextComponentMixin, Serializable
public class SJPasswordField
extends com.vaadin.flow.component.textfield.PasswordField
implements JTextComponentMixin, EnterClaims.Claimant
Surrogate for Override surface against
JTextField-shape surface (duplicated from
JPasswordField, a consumer of SD_sjtextfield's
JTextComponentMixin. Extends Vaadin
PasswordField directly (is-a). Reaches the migrator either
through :emulators.JPasswordField as peer, or as a richer-than-
stock Vaadin component in its own right.
Why PasswordField as peer (not TextField)
VaadinPasswordField renders <input type="password">,
giving a native browser-side mask glyph plus optional reveal button —
the exact functionality JPasswordField exists to provide. PasswordField
extends TextFieldBase (not
TextField), so SJPasswordField
cannot inherit from SJTextField — instead the JTextField-shaped
surface (columns / ActionListener-on-Enter / setAction / horizontalAlignment)
is duplicated here. JDK JPasswordField extends
JTextField so this surface is part of JPasswordField's
contract; the duplication is the price of Vaadin's parallel-not-shared
peer hierarchy. Could be lifted into a JTextFieldMixin later if
a third consumer arrives — for now two consumers don't justify the lift.
Override surface against JTextComponentMixin
validate()— visibility-widening override required byComponentMixin's publicvalidate()contract. VaadinPasswordFielddeclares inheritedvalidate()asprotected(input validation, not Swing's layout cycle). Same shape SJTextField and SJToggleButton take per SD_sjtextfield / SD_toggle_checkbox_first_cut.
getText() is not overridden and returns cleartext, matching
the JDK. See SD_sjpasswordfield's correction note: echoChar is a
rendering concern only.
JPasswordField-specific surface
echoChar— default'*'. State round-trip only: no getter here reads it, exactly as in the JDK, where onlyBasicPasswordFieldUI's view consults it.setEchoChar(char)fires nothing — the JDK's setter is not bound. The rendered mask is governed by<input type="password">client-side (Vaadin exposes no server-side toggle), so the visual stays masked regardless. Toggling the masked-vs-cleartext boundary (i.e.echoChar=0) WARNs per R_match_swing_errors sub-bucket (c) — seesetEchoChar(char)for the full rationale and thePasswordField.setRevealButtonVisible(boolean)alternative.getPassword()— returns a freshchar[]snapshot of the Document's contents. Caller is expected to zero the array after use so the cleartext password doesn't linger in the heap as a String.copy/cut— inherited from the mixin'sSHelper.onUnimplemented(Object, String, Object...)default. JDK beeps and refuses to keep cleartext out of the system clipboard; our WARN and-drop is the closest equivalent and keeps clipboard-safe semantics under R_match_swing_errors.getUIClassID() == "PasswordFieldUI".
JTextField-shape surface (duplicated from SJTextField)
columns—setColumns(int)writespeer.setWidthof aCssConvert.columnsToCssWidth(int)character-column hint per R_layouts_close_enough close-enough; negative throws IAE per R_match_swing_errors.horizontalAlignment— drop-and-WARN per SD_sjtextfield (Vaadin shadow DOM doesn't honor host text-align). R_match_swing_errors IAE on bad axis preserved.- ActionListener wiring on Enter — Vaadin
addKeyPressListener(Key.ENTER, ...)firesActionEventwith source = this and actionCommand falling back to text. Note: theActionEventcarries the cleartext (the Document's text), not the masked form — this matches JDK JTextField behaviour and keeps form-submit handlers working without a special-case for password fields. setAction(Action)— narrow propagation per JDK JTextField:enabled/SHORT_DESCRIPTION/ACTION_COMMAND_KEYonly.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.textfield.PasswordField
com.vaadin.flow.component.textfield.PasswordField.PasswordFieldI18nNested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E>Nested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
AUTOCAPITALIZE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTEFields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUTFields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
ConstructorsConstructorDescriptionSJPasswordField(int columns) SJPasswordField(String text) SJPasswordField(String text, int columns) SJPasswordField(Document doc, String text, int columns) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactionPropertyChanged(Action a, String propertyName) voidbooleanprotected voidJDK JTextField's narrow Action property set:enabled/SHORT_DESCRIPTION/ACTION_COMMAND_KEY.protected PropertyChangeListenerbooleanTrue iffechoChar != 0.protected voidFire ActionEvent with source = this.intcharintchar[]Return a freshchar[]snapshot of the Document's contents.Deliberate no-op — L&F key.protected StringJDK JPasswordField.paramString chains JTextField's tail and appends the raw echoChar, unmasked.voidPublic synthesizer matching JDK — useful when not Enter-triggered.voidvoidvoidsetActionCommand(String command) voidsetColumns(int columns) voidsetEchoChar(char c) Set the echo character the L&F would paint.voidsetHorizontalAlignment(int alignment) voidvalidate()Visibility-widening override ofPasswordField.validate()to satisfyComponentMixin's publicvalidate()contract.Methods inherited from class com.vaadin.flow.component.textfield.PasswordField
getDefaultValidator, getEmptyValue, getI18n, getMaxLength, getMinLength, getPattern, getValue, isRevealButtonVisible, setErrorMessage, setI18n, setManualValidation, setMaxLength, setMinLength, setPattern, setRequiredIndicatorVisible, setRevealButtonVisible, setValueMethods inherited from class com.vaadin.flow.component.textfield.TextFieldBase
addToInput, addToPrefix, addToSuffix, getAriaDescribedBy, getAriaLabel, getAriaLabelledBy, getTitle, getValueChangeMode, getValueChangeTimeout, isAutofocus, isAutoselect, isRequired, isRequiredIndicatorVisible, setAriaDescribedBy, setAriaLabel, setAriaLabelledBy, setAutofocus, setAutoselect, setLabel, setRequired, setTitle, setValueChangeMode, setValueChangeTimeoutMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, bindValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, updateMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasAllowedCharPattern
getAllowedCharPattern, setAllowedCharPatternMethods inherited from interface com.vaadin.flow.component.HasAriaDescription
setAriaDescribedByMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalizeMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocompleteMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrectMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
bindClearButtonVisible, isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabelMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
bindPlaceholder, getPlaceholder, setPlaceholderMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListenerMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, bindValue, clear, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, setReadOnlyMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardActionMethods inherited from interface JTextComponentMixin
addCaretChangeListener, addCaretListener, addSelectionReportListener, copy, createDefaultDocument, cut, getActions, getCaret, getCaretColor, getCaretListeners, getCaretMark, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropMode, getFocusAccelerator, getHighlighter, getKeymap, getMargin, getNavigationFilter, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, installSelectionBridge, installTextComponentBindings, isEditable, modelToView, modelToView2D, moveCaretPosition, paste, print, read, removeCaretChangeListener, removeCaretListener, renderSelection, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setDocument, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, viewToModel2D, writeMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
SJPasswordField
public SJPasswordField() -
SJPasswordField
-
SJPasswordField
public SJPasswordField(int columns) -
SJPasswordField
-
SJPasswordField
-
-
Method Details
-
validate
public void validate()Visibility-widening override ofPasswordField.validate()to satisfyComponentMixin's publicvalidate()contract. Delegates to super so Vaadin's input-validation behaviour is preserved.- Specified by:
validatein interfaceComponentMixin- Overrides:
validatein classcom.vaadin.flow.component.textfield.PasswordField
-
getEchoChar
public char getEchoChar() -
setEchoChar
public void setEchoChar(char c) Set the echo character the L&F would paint. Fires nothing: the JDK's setter assigns, repaints and revalidates (SD_property_fanout_audit).Vaadin
PasswordFieldhas no server-side API to flip the underlying<input>element'stypeattribute — the masked-vs-cleartext visual is governed entirely client-side by the reveal button (eye icon). SinceechoCharis a rendering input and nothing server-side renders text here, the write is pure state: it reaches no observable behaviour at all. Two divergence shapes:- Masked-vs-not — toggling
echoChar=0(JDK "show cleartext") on or off does not unmask the input visually. WARNs viaSHelper.onUnimplemented(Object, String, Object...)per R_match_swing_errors sub-bucket (c) so migrators discover the no-op in the log. Migrated apps that togglesetEchoChar(0)for a "show password" UX should switch toPasswordField.setRevealButtonVisible(boolean)(default visible) and let the user click the eye icon. - Glyph — changing between two non-zero echo chars
(default
'*'→'#') is silently accepted. The browser renders<input type=password>'s native glyph regardless; documented divergence, not a WARN, since most apps stay on the default and the user-visible impact of "wrong masking glyph but still masked" is small.
- Masked-vs-not — toggling
-
echoCharIsSet
public boolean echoCharIsSet()True iffechoChar != 0. JDK special case: 0 means "paint cleartext". -
getPassword
public char[] getPassword()Return a freshchar[]snapshot of the Document's contents. Caller is expected to zero the array after use so the cleartext password doesn't linger in the heap. Empty Document returns an empty array (matches JDK). -
getColumns
public int getColumns() -
setColumns
public void setColumns(int columns) -
getHorizontalAlignment
public int getHorizontalAlignment() -
setHorizontalAlignment
public void setHorizontalAlignment(int alignment) -
addActionListener
-
removeActionListener
-
getActionListeners
-
claimsEnter
public boolean claimsEnter()- Specified by:
claimsEnterin interfaceEnterClaims.Claimant
-
fireActionPerformed
protected void fireActionPerformed()Fire ActionEvent with source = this.actionCommandfalls back toJTextComponentMixin.getText()— the same one-linerSJTextFieldcarries, because JDK JPasswordField inherits JTextField's fallback unchanged. -
setActionCommand
-
postActionEvent
public void postActionEvent()Public synthesizer matching JDK — useful when not Enter-triggered. -
getAction
-
setAction
-
configurePropertiesFromAction
JDK JTextField's narrow Action property set:enabled/SHORT_DESCRIPTION/ACTION_COMMAND_KEY. No NAME propagation (would overwrite form data) or icons or mnemonics. -
createActionPropertyChangeListener
-
actionPropertyChanged
-
getUIClassID
Description copied from interface:JComponentMixinDeliberate no-op — L&F key.- Specified by:
getUIClassIDin interfaceJComponentMixin
-
paramString
JDK JPasswordField.paramString chains JTextField's tail and appends the raw echoChar, unmasked. We follow the same shape; underlying VaadinComponent.toStringis the honest host-side equivalent. -
getAccessibleContext
-