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
,javax.swing.text.ViewFactory
- Direct Known Subclasses:
FlatFormattedTextFieldUI
,FlatPasswordFieldUI
public class FlatTextFieldUI extends javax.swing.plaf.basic.BasicTextFieldUI implements FlatStylingSupport.StyleableUI
Provides the Flat LaF UI delegate forJTextField
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FlatTextFieldUI.FlatDocumentListener
private class
FlatTextFieldUI.FlatTextFieldLayout
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
background
private java.util.concurrent.atomic.AtomicBoolean
borderShared
protected javax.swing.JComponent
clearButton
private java.awt.Insets
defaultMargin
protected java.awt.Color
disabledBackground
private javax.swing.event.DocumentListener
documentListener
protected java.awt.Color
focusedBackground
private java.awt.event.FocusListener
focusListener
protected int
iconTextGap
protected java.awt.Color
inactiveBackground
protected javax.swing.JComponent
leadingComponent
protected javax.swing.Icon
leadingIcon
protected int
minimumWidth
private java.awt.Color
oldDisabledBackground
private java.awt.Color
oldInactiveBackground
private java.util.Map<java.lang.String,java.lang.Object>
oldStyleValues
protected java.awt.Color
placeholderForeground
protected boolean
showClearButton
protected javax.swing.JComponent
trailingComponent
protected javax.swing.Icon
trailingIcon
-
Constructor Summary
Constructors Constructor Description FlatTextFieldUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.awt.Dimension
applyExtraSize(java.awt.Dimension size)
private java.awt.Dimension
applyMinimumWidth(javax.swing.JComponent c, java.awt.Dimension size, int minimumWidth)
protected void
applyStyle(java.lang.Object style)
protected java.lang.Object
applyStyleProperty(java.lang.String key, java.lang.Object value)
protected void
clearButtonClicked()
protected javax.swing.text.Caret
createCaret()
protected javax.swing.JComponent
createClearButton()
static javax.swing.plaf.ComponentUI
createUI(javax.swing.JComponent c)
protected void
documentChanged(javax.swing.event.DocumentEvent e)
(package private) static java.awt.Color
getBackground(javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)
protected java.awt.Rectangle
getIconsRect()
Returns the rectangle used to paint leading and trailing icons.protected javax.swing.JComponent[]
getLeadingComponents()
Returns components placed at the leading side of the text field.protected int
getLeadingIconWidth()
java.awt.Dimension
getMinimumSize(javax.swing.JComponent c)
protected java.awt.Insets
getPadding()
java.awt.Dimension
getPreferredSize(javax.swing.JComponent c)
java.util.Map<java.lang.String,java.lang.Class<?>>
getStyleableInfos(javax.swing.JComponent c)
java.lang.Object
getStyleableValue(javax.swing.JComponent c, java.lang.String key)
(package private) java.lang.String
getStyleType()
protected javax.swing.JComponent[]
getTrailingComponents()
Returns components placed at the trailing side of the text field.protected int
getTrailingIconWidth()
protected java.awt.Rectangle
getVisibleEditorRect()
Returns the rectangle used for the root view of the text.(package private) static boolean
hasDefaultMargins(javax.swing.JComponent c, java.awt.Insets defaultMargin)
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(javax.swing.JComponent c)
private void
installUIImpl(javax.swing.JComponent c)
(package private) boolean
isLeftToRight()
protected void
paintBackground(java.awt.Graphics g)
(package private) static void
paintBackground(java.awt.Graphics g, javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)
protected void
paintIcons(java.awt.Graphics g, java.awt.Rectangle r)
Paints the leading and trailing icons in the given rectangle.protected void
paintPlaceholder(java.awt.Graphics g)
protected void
paintSafely(java.awt.Graphics g)
protected void
prepareLeadingOrTrailingComponent(javax.swing.JComponent c)
protected void
propertyChange(java.beans.PropertyChangeEvent e)
protected void
scrollCaretToVisible()
protected void
uninstallClearButton()
protected void
uninstallDefaults()
protected void
uninstallLeadingComponent()
protected void
uninstallListeners()
protected void
uninstallTrailingComponent()
void
uninstallUI(javax.swing.JComponent c)
private void
updateBackground()
(package private) static void
updateBackground(javax.swing.text.JTextComponent c, java.awt.Color background, java.awt.Color disabledBackground, java.awt.Color inactiveBackground, java.awt.Color oldDisabledBackground, java.awt.Color oldInactiveBackground)
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
-
-
-
-
Field Detail
-
minimumWidth
protected int minimumWidth
-
background
private java.awt.Color background
-
disabledBackground
protected java.awt.Color disabledBackground
-
inactiveBackground
protected java.awt.Color inactiveBackground
-
placeholderForeground
protected java.awt.Color placeholderForeground
-
focusedBackground
protected java.awt.Color focusedBackground
-
iconTextGap
protected int iconTextGap
- Since:
- 2
-
leadingIcon
protected javax.swing.Icon leadingIcon
- Since:
- 2
-
trailingIcon
protected javax.swing.Icon trailingIcon
- Since:
- 2
-
leadingComponent
protected javax.swing.JComponent leadingComponent
- Since:
- 2
-
trailingComponent
protected javax.swing.JComponent trailingComponent
- Since:
- 2
-
clearButton
protected javax.swing.JComponent clearButton
- Since:
- 2
-
showClearButton
protected boolean showClearButton
- Since:
- 2
-
oldDisabledBackground
private java.awt.Color oldDisabledBackground
-
oldInactiveBackground
private java.awt.Color oldInactiveBackground
-
defaultMargin
private java.awt.Insets defaultMargin
-
focusListener
private java.awt.event.FocusListener focusListener
-
documentListener
private javax.swing.event.DocumentListener documentListener
-
oldStyleValues
private java.util.Map<java.lang.String,java.lang.Object> oldStyleValues
-
borderShared
private java.util.concurrent.atomic.AtomicBoolean borderShared
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
-
installUI
public void installUI(javax.swing.JComponent c)
- Overrides:
installUI
in classjavax.swing.plaf.basic.BasicTextUI
-
installUIImpl
private void installUIImpl(javax.swing.JComponent c)
-
uninstallUI
public void uninstallUI(javax.swing.JComponent c)
- Overrides:
uninstallUI
in classjavax.swing.plaf.basic.BasicTextUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaults
in classjavax.swing.plaf.basic.BasicTextUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaults
in classjavax.swing.plaf.basic.BasicTextUI
-
installListeners
protected void installListeners()
- Overrides:
installListeners
in classjavax.swing.plaf.basic.BasicTextUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListeners
in classjavax.swing.plaf.basic.BasicTextUI
-
createCaret
protected javax.swing.text.Caret createCaret()
- Overrides:
createCaret
in classjavax.swing.plaf.basic.BasicTextUI
-
propertyChange
protected void propertyChange(java.beans.PropertyChangeEvent e)
- Overrides:
propertyChange
in classjavax.swing.plaf.basic.BasicTextUI
-
installDocumentListener
protected void installDocumentListener()
- Since:
- 2
-
documentChanged
protected void documentChanged(javax.swing.event.DocumentEvent e)
- Since:
- 2
-
installStyle
protected void installStyle()
- Since:
- 2
-
getStyleType
java.lang.String getStyleType()
- Since:
- 2
-
applyStyle
protected void applyStyle(java.lang.Object style)
- Since:
- 2
-
applyStyleProperty
protected java.lang.Object applyStyleProperty(java.lang.String key, java.lang.Object value)
- Since:
- 2
-
getStyleableInfos
public java.util.Map<java.lang.String,java.lang.Class<?>> getStyleableInfos(javax.swing.JComponent c)
- Specified by:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)
- Specified by:
getStyleableValue
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2.5
-
updateBackground
private void updateBackground()
-
updateBackground
static void updateBackground(javax.swing.text.JTextComponent c, java.awt.Color background, java.awt.Color disabledBackground, java.awt.Color inactiveBackground, java.awt.Color oldDisabledBackground, java.awt.Color oldInactiveBackground)
-
paintSafely
protected void paintSafely(java.awt.Graphics g)
- Overrides:
paintSafely
in classjavax.swing.plaf.basic.BasicTextUI
-
paintBackground
protected void paintBackground(java.awt.Graphics g)
- Overrides:
paintBackground
in classjavax.swing.plaf.basic.BasicTextUI
-
paintBackground
static void paintBackground(java.awt.Graphics g, javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)
-
getBackground
static java.awt.Color getBackground(javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)
-
paintPlaceholder
protected void paintPlaceholder(java.awt.Graphics g)
-
paintIcons
protected void paintIcons(java.awt.Graphics g, java.awt.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 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
- Overrides:
getPreferredSize
in classjavax.swing.plaf.basic.BasicTextUI
-
getMinimumSize
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
- Overrides:
getMinimumSize
in classjavax.swing.plaf.basic.BasicTextUI
-
applyExtraSize
private java.awt.Dimension applyExtraSize(java.awt.Dimension size)
-
applyMinimumWidth
private java.awt.Dimension applyMinimumWidth(javax.swing.JComponent c, java.awt.Dimension size, int minimumWidth)
-
hasDefaultMargins
static boolean hasDefaultMargins(javax.swing.JComponent c, java.awt.Insets defaultMargin)
-
getVisibleEditorRect
protected java.awt.Rectangle getVisibleEditorRect()
Returns the rectangle used for the root view of the text. This method is used to place the text.- Overrides:
getVisibleEditorRect
in classjavax.swing.plaf.basic.BasicTextUI
-
getIconsRect
protected java.awt.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
-
isLeftToRight
boolean isLeftToRight()
-
getPadding
protected java.awt.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 javax.swing.JComponent createClearButton()
- Since:
- 2
-
clearButtonClicked
protected void clearButtonClicked()
- Since:
- 2
-
updateClearButton
protected void updateClearButton()
- Since:
- 2
-
getLeadingComponents
protected javax.swing.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 javax.swing.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(javax.swing.JComponent c)
- Since:
- 2
-
installLayout
protected void installLayout()
- Since:
- 2
-
-