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 JComponent
clearButton
protected Color
disabledBackground
protected Color
focusedBackground
protected int
iconTextGap
protected Color
inactiveBackground
protected boolean
isIntelliJTheme
protected JComponent
leadingComponent
protected Icon
leadingIcon
protected int
minimumWidth
protected Color
placeholderForeground
protected boolean
showClearButton
protected JComponent
trailingComponent
protected Icon
trailingIcon
-
Constructor Summary
Constructors Constructor Description FlatTextFieldUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyStyle(Object style)
protected Object
applyStyleProperty(String key, Object value)
protected void
clearButtonClicked()
protected Caret
createCaret()
protected JComponent
createClearButton()
static ComponentUI
createUI(JComponent c)
protected void
documentChanged(DocumentEvent e)
protected Rectangle
getIconsRect()
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 int
getLeadingIconWidth()
Dimension
getMinimumSize(JComponent c)
protected Insets
getPadding()
Dimension
getPreferredSize(JComponent c)
Map<String,Class<?>>
getStyleableInfos(JComponent c)
Object
getStyleableValue(JComponent c, String key)
protected JComponent[]
getTrailingComponents()
Returns components placed at the trailing side of the text field.protected int
getTrailingIconWidth()
protected Rectangle
getVisibleEditorRect()
Returns the rectangle used for the root view of the text.protected boolean
hasLeadingIcon()
protected boolean
hasTrailingIcon()
protected void
installClearButton()
protected void
installDefaults()
protected void
installDocumentListener()
protected void
installLayout()
protected void
installLeadingComponent()
protected void
installListeners()
protected void
installStyle()
protected void
installTrailingComponent()
void
installUI(JComponent c)
protected void
paintBackground(Graphics g)
protected void
paintIcons(Graphics g, Rectangle r)
Paints the leading and trailing icons in the given rectangle.protected void
paintPlaceholder(Graphics g)
protected void
paintSafely(Graphics g)
protected void
prepareLeadingOrTrailingComponent(JComponent c)
protected void
propertyChange(PropertyChangeEvent e)
protected void
scrollCaretToVisible()
protected void
uninstallClearButton()
protected void
uninstallDefaults()
protected void
uninstallLeadingComponent()
protected void
uninstallListeners()
protected void
uninstallTrailingComponent()
void
uninstallUI(JComponent c)
protected void
updateClearButton()
-
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:
installUI
in classBasicTextUI
-
uninstallUI
public void uninstallUI(JComponent c)
- Overrides:
uninstallUI
in classBasicTextUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaults
in classBasicTextUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaults
in classBasicTextUI
-
installListeners
protected void installListeners()
- Overrides:
installListeners
in classBasicTextUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListeners
in classBasicTextUI
-
createCaret
protected Caret createCaret()
- Overrides:
createCaret
in classBasicTextUI
-
propertyChange
protected void propertyChange(PropertyChangeEvent e)
- Overrides:
propertyChange
in 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:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
public Object getStyleableValue(JComponent c, String key)
- Specified by:
getStyleableValue
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2.5
-
paintSafely
protected void paintSafely(Graphics g)
- Overrides:
paintSafely
in classBasicTextUI
-
paintBackground
protected void paintBackground(Graphics g)
- Overrides:
paintBackground
in 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:
getPreferredSize
in classBasicTextUI
-
getMinimumSize
public Dimension getMinimumSize(JComponent c)
- Overrides:
getMinimumSize
in 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:
getVisibleEditorRect
in 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 returnstrailingComponent
andclearButton
.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
-
-