Class AutoSizingTextField

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

public final class AutoSizingTextField extends JTextField
Text field whose preferred width tracks its content length within clamped bounds.

EDT: sizing is queried on the EDT by Swing.

See Also:
  • Constructor Details

    • AutoSizingTextField

      public AutoSizingTextField(String text)
      Creates an auto-sizing text field seeded with the given text.
      Parameters:
      text - initial content (nullable)
  • Method Details

    • getPreferredSize

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

      public JToolTip createToolTip()
      Overrides:
      createToolTip in class JComponent