Package com.formdev.flatlaf.ui
Class FlatTextFieldUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TextUI
-
- javax.swing.plaf.basic.BasicTextUI
-
- javax.swing.plaf.basic.BasicTextFieldUI
-
- com.formdev.flatlaf.ui.FlatTextFieldUI
-
- All Implemented Interfaces:
FlatStylingSupport.StyleableUI,ViewFactory
- Direct Known Subclasses:
FlatFormattedTextFieldUI,FlatPasswordFieldUI
public class FlatTextFieldUI extends BasicTextFieldUI implements FlatStylingSupport.StyleableUI
Provides the Flat LaF UI delegate forJTextField.- UiDefault:
- TextField.font Font, TextField.background Color, TextField.foreground Color also used if not editable, TextField.caretForeground Color, TextField.selectionBackground Color, TextField.selectionForeground Color, TextField.disabledBackground Color used if not enabled, TextField.inactiveBackground Color used if not editable, TextField.inactiveForeground Color used if not enabled (yes, this is confusing; this should be named disabledForeground), TextField.border Border, TextField.margin Insets, TextField.caretBlinkRate int default is 500 milliseconds , Component.minimumWidth int, Component.isIntelliJTheme boolean, TextField.placeholderForeground Color, TextField.focusedBackground Color optional, TextField.iconTextGap int optional, default is 4, TextComponent.selectAllOnFocusPolicy String never, once (default) or always, TextComponent.selectAllOnMouseClick boolean
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTextUI
BasicTextUI.BasicCaret, BasicTextUI.BasicHighlighter
-
-
Field Summary
Fields Modifier and Type Field Description protected JComponentclearButtonprotected ColordisabledBackgroundprotected ColorfocusedBackgroundprotected inticonTextGapprotected ColorinactiveBackgroundprotected booleanisIntelliJThemeprotected JComponentleadingComponentprotected IconleadingIconprotected intminimumWidthprotected ColorplaceholderForegroundprotected booleanshowClearButtonprotected JComponenttrailingComponentprotected IcontrailingIcon
-
Constructor Summary
Constructors Constructor Description FlatTextFieldUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyStyle(Object style)protected ObjectapplyStyleProperty(String key, Object value)protected voidclearButtonClicked()protected CaretcreateCaret()protected JComponentcreateClearButton()static ComponentUIcreateUI(JComponent c)protected voiddocumentChanged(DocumentEvent e)protected RectanglegetIconsRect()Returns the rectangle used to paint leading and trailing icons.protected JComponent[]getLeadingComponents()Returns components placed at the leading side of the text field.protected intgetLeadingIconWidth()DimensiongetMinimumSize(JComponent c)protected InsetsgetPadding()DimensiongetPreferredSize(JComponent c)Map<String,Class<?>>getStyleableInfos(JComponent c)ObjectgetStyleableValue(JComponent c, String key)protected JComponent[]getTrailingComponents()Returns components placed at the trailing side of the text field.protected intgetTrailingIconWidth()protected RectanglegetVisibleEditorRect()Returns the rectangle used for the root view of the text.protected booleanhasLeadingIcon()protected booleanhasTrailingIcon()protected voidinstallClearButton()protected voidinstallDefaults()protected voidinstallDocumentListener()protected voidinstallLayout()protected voidinstallLeadingComponent()protected voidinstallListeners()protected voidinstallStyle()protected voidinstallTrailingComponent()voidinstallUI(JComponent c)protected voidpaintBackground(Graphics g)protected voidpaintIcons(Graphics g, Rectangle r)Paints the leading and trailing icons in the given rectangle.protected voidpaintPlaceholder(Graphics g)protected voidpaintSafely(Graphics g)protected voidprepareLeadingOrTrailingComponent(JComponent c)protected voidpropertyChange(PropertyChangeEvent e)protected voidscrollCaretToVisible()protected voiduninstallClearButton()protected voiduninstallDefaults()protected voiduninstallLeadingComponent()protected voiduninstallListeners()protected voiduninstallTrailingComponent()voiduninstallUI(JComponent c)protected voidupdateClearButton()-
Methods inherited from class javax.swing.plaf.basic.BasicTextFieldUI
create, getBaseline, getBaselineResizeBehavior, getPropertyPrefix
-
Methods inherited from class javax.swing.plaf.basic.BasicTextUI
create, createHighlighter, createKeymap, damageRange, damageRange, getComponent, getEditorKit, getKeymapName, getMaximumSize, getNextVisualPositionFrom, getRootView, getToolTipText, installKeyboardActions, modelChanged, modelToView, modelToView, modelToView2D, paint, setView, uninstallKeyboardActions, update, viewToModel, viewToModel, viewToModel2D
-
Methods inherited from class javax.swing.plaf.TextUI
getToolTipText2D
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
-
-
-
-
Field Detail
-
minimumWidth
protected int minimumWidth
-
isIntelliJTheme
protected boolean isIntelliJTheme
-
disabledBackground
protected Color disabledBackground
-
inactiveBackground
protected Color inactiveBackground
-
placeholderForeground
protected Color placeholderForeground
-
focusedBackground
protected Color focusedBackground
-
iconTextGap
protected int iconTextGap
- Since:
- 2
-
leadingIcon
protected Icon leadingIcon
- Since:
- 2
-
trailingIcon
protected Icon trailingIcon
- Since:
- 2
-
leadingComponent
protected JComponent leadingComponent
- Since:
- 2
-
trailingComponent
protected JComponent trailingComponent
- Since:
- 2
-
clearButton
protected JComponent clearButton
- Since:
- 2
-
showClearButton
protected boolean showClearButton
- Since:
- 2
-
-
Method Detail
-
createUI
public static ComponentUI createUI(JComponent c)
-
installUI
public void installUI(JComponent c)
- Overrides:
installUIin classBasicTextUI
-
uninstallUI
public void uninstallUI(JComponent c)
- Overrides:
uninstallUIin classBasicTextUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaultsin classBasicTextUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaultsin classBasicTextUI
-
installListeners
protected void installListeners()
- Overrides:
installListenersin classBasicTextUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListenersin classBasicTextUI
-
createCaret
protected Caret createCaret()
- Overrides:
createCaretin classBasicTextUI
-
propertyChange
protected void propertyChange(PropertyChangeEvent e)
- Overrides:
propertyChangein classBasicTextUI
-
installDocumentListener
protected void installDocumentListener()
- Since:
- 2
-
documentChanged
protected void documentChanged(DocumentEvent e)
- Since:
- 2
-
installStyle
protected void installStyle()
- Since:
- 2
-
applyStyle
protected void applyStyle(Object style)
- Since:
- 2
-
getStyleableInfos
public Map<String,Class<?>> getStyleableInfos(JComponent c)
- Specified by:
getStyleableInfosin interfaceFlatStylingSupport.StyleableUI- Since:
- 2
-
getStyleableValue
public Object getStyleableValue(JComponent c, String key)
- Specified by:
getStyleableValuein interfaceFlatStylingSupport.StyleableUI- Since:
- 2.5
-
paintSafely
protected void paintSafely(Graphics g)
- Overrides:
paintSafelyin classBasicTextUI
-
paintBackground
protected void paintBackground(Graphics g)
- Overrides:
paintBackgroundin classBasicTextUI
-
paintPlaceholder
protected void paintPlaceholder(Graphics g)
-
paintIcons
protected void paintIcons(Graphics g, Rectangle r)
Paints the leading and trailing icons in the given rectangle. The rectangle is updated by this method so that subclasses can use it without painting over leading or trailing icons.- Since:
- 2
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
- Overrides:
getPreferredSizein classBasicTextUI
-
getMinimumSize
public Dimension getMinimumSize(JComponent c)
- Overrides:
getMinimumSizein classBasicTextUI
-
getVisibleEditorRect
protected Rectangle getVisibleEditorRect()
Returns the rectangle used for the root view of the text. This method is used to place the text.- Overrides:
getVisibleEditorRectin classBasicTextUI
-
getIconsRect
protected Rectangle getIconsRect()
Returns the rectangle used to paint leading and trailing icons. It invokessuper.getVisibleEditorRect()and reduces left and/or right margin if the text field has leading or trailing icons or components. Also, the preferred widths of leading and trailing components are removed.- Since:
- 2
-
hasLeadingIcon
protected boolean hasLeadingIcon()
- Since:
- 2
-
hasTrailingIcon
protected boolean hasTrailingIcon()
- Since:
- 2
-
getLeadingIconWidth
protected int getLeadingIconWidth()
- Since:
- 2
-
getTrailingIconWidth
protected int getTrailingIconWidth()
- Since:
- 2
-
getPadding
protected Insets getPadding()
- Since:
- 1.4
-
scrollCaretToVisible
protected void scrollCaretToVisible()
- Since:
- 1.4
-
installLeadingComponent
protected void installLeadingComponent()
- Since:
- 2
-
installTrailingComponent
protected void installTrailingComponent()
- Since:
- 2
-
uninstallLeadingComponent
protected void uninstallLeadingComponent()
- Since:
- 2
-
uninstallTrailingComponent
protected void uninstallTrailingComponent()
- Since:
- 2
-
installClearButton
protected void installClearButton()
- Since:
- 2
-
uninstallClearButton
protected void uninstallClearButton()
- Since:
- 2
-
createClearButton
protected JComponent createClearButton()
- Since:
- 2
-
clearButtonClicked
protected void clearButtonClicked()
- Since:
- 2
-
updateClearButton
protected void updateClearButton()
- Since:
- 2
-
getLeadingComponents
protected JComponent[] getLeadingComponents()
Returns components placed at the leading side of the text field. The returned array may containnull. The default implementation returnsleadingComponent.- Since:
- 2
-
getTrailingComponents
protected JComponent[] getTrailingComponents()
Returns components placed at the trailing side of the text field. The returned array may containnull. The default implementation returnstrailingComponentandclearButton.Note: The components in the array must be in reverse (visual) order.
- Since:
- 2
-
prepareLeadingOrTrailingComponent
protected void prepareLeadingOrTrailingComponent(JComponent c)
- Since:
- 2
-
installLayout
protected void installLayout()
- Since:
- 2
-
-