Class AutoSizingPasswordField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public final class AutoSizingPasswordField extends JPasswordField
Password field whose preferred width tracks its content length within clamped bounds. Uses character count only (not actual characters) for sizing.

EDT: sizing is queried on the EDT by Swing.

See Also:
  • Constructor Details

    • AutoSizingPasswordField

      public AutoSizingPasswordField()
      Creates an auto-sizing password field.
  • Method Details

    • getPreferredSize

      public Dimension getPreferredSize()
      Computes preferred size based on content length (character count), clamped between 80 and 900 with padding.
      Overrides:
      getPreferredSize in class JTextField
      Returns:
      preferred dimension reflecting current content length
    • createToolTip

      public JToolTip createToolTip()
      Overrides:
      createToolTip in class JComponent