Class FlatFormattedTextField

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

public class FlatFormattedTextField extends JFormattedTextField implements FlatComponentExtension, FlatStyleableComponent
Subclass of JFormattedTextField that provides easy access to FlatLaf specific client properties.
See Also:
  • Constructor Details

    • FlatFormattedTextField

      public FlatFormattedTextField()
  • Method Details

    • getPlaceholderText

      public String getPlaceholderText()
      Returns the placeholder text that is only painted if the text field is empty.
    • setPlaceholderText

      public void setPlaceholderText(String placeholderText)
      Sets the placeholder text that is only painted if the text field is empty.
    • getLeadingIcon

      public Icon getLeadingIcon()
      Returns the leading icon that will be placed at the leading edge of the text field.
      Since:
      2
    • setLeadingIcon

      public void setLeadingIcon(Icon leadingIcon)
      Specifies the leading icon that will be placed at the leading edge of the text field.
      Since:
      2
    • getTrailingIcon

      public Icon getTrailingIcon()
      Returns the trailing icon that will be placed at the trailing edge of the text field.
      Since:
      2
    • setTrailingIcon

      public void setTrailingIcon(Icon trailingIcon)
      Specifies the trailing icon that will be placed at the trailing edge of the text field.
      Since:
      2
    • getLeadingComponent

      public JComponent getLeadingComponent()
      Returns a component that will be placed at the leading edge of the text field.
      Since:
      2
    • setLeadingComponent

      public void setLeadingComponent(JComponent leadingComponent)
      Specifies a component that will be placed at the leading edge of the text field.

      The component will be positioned inside and aligned to the visible text field border. There is no gap between the visible border and the component. The laid out component size will be the preferred component width and the inner text field height.

      The component should be not opaque because the text field border is painted slightly inside the usually visible border in some cases. E.g. when focused (in some themes) or when an outline color is specified (see setOutline(Object)).

      Since:
      2
    • getTrailingComponent

      public JComponent getTrailingComponent()
      Returns a component that will be placed at the trailing edge of the text field.
      Since:
      2
    • setTrailingComponent

      public void setTrailingComponent(JComponent trailingComponent)
      Specifies a component that will be placed at the trailing edge of the text field.

      The component will be positioned inside and aligned to the visible text field border. There is no gap between the visible border and the component. The laid out component size will be the preferred component width and the inner text field height.

      The component should be not opaque because the text field border is painted slightly inside the usually visible border in some cases. E.g. when focused (in some themes) or when an outline color is specified (see setOutline(Object)).

      Since:
      2
    • isShowClearButton

      public boolean isShowClearButton()
      Returns whether a "clear" (or "cancel") button is shown.
      Since:
      2
    • setShowClearButton

      public void setShowClearButton(boolean showClearButton)
      Specifies whether a "clear" (or "cancel") button is shown on the trailing side if the text field is not empty, editable and enabled.
      Since:
      2
    • getSelectAllOnFocusPolicy

      public FlatTextField.SelectAllOnFocusPolicy getSelectAllOnFocusPolicy()
      Returns whether all text is selected when the text component gains focus.
    • setSelectAllOnFocusPolicy

      public void setSelectAllOnFocusPolicy(FlatTextField.SelectAllOnFocusPolicy selectAllOnFocusPolicy)
      Specifies whether all text is selected when the text component gains focus.
    • getPadding

      public Insets getPadding()
      Returns the padding of the text.
      Since:
      1.4
    • setPadding

      public void setPadding(Insets padding)
      Specifies the padding of the text. This changes the location and size of the text view within the component bounds, but does not affect the size of the component.
      Since:
      1.4
    • getMinimumWidth

      public int getMinimumWidth()
      Returns minimum width of a component.
    • setMinimumWidth

      public void setMinimumWidth(int minimumWidth)
      Specifies minimum width of a component.
    • isRoundRect

      public boolean isRoundRect()
      Returns whether the component is painted with round edges.
    • setRoundRect

      public void setRoundRect(boolean roundRect)
      Specifies whether the component is painted with round edges.
    • getOutline

      public Object getOutline()
      Returns the outline color of the component border.
    • setOutline

      public void setOutline(Object outline)
      Specifies the outline color of the component border.

      Allowed Values are:

      • null
      • string "error"
      • string "warning"
      • any color (type Color)
      • an array of two colors (type Color[2]) where the first color is for focused state and the second for unfocused state