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 classFlatTextFieldUI.FlatDocumentListenerprivate classFlatTextFieldUI.FlatTextFieldLayout
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Colorbackgroundprivate java.util.concurrent.atomic.AtomicBooleanborderSharedprotected javax.swing.JComponentclearButtonprivate java.awt.InsetsdefaultMarginprotected java.awt.ColordisabledBackgroundprivate javax.swing.event.DocumentListenerdocumentListenerprotected java.awt.ColorfocusedBackgroundprivate java.awt.event.FocusListenerfocusListenerprotected inticonTextGapprotected java.awt.ColorinactiveBackgroundprotected javax.swing.JComponentleadingComponentprotected javax.swing.IconleadingIconprotected intminimumWidthprivate java.awt.ColoroldDisabledBackgroundprivate java.awt.ColoroldInactiveBackgroundprivate java.util.Map<java.lang.String,java.lang.Object>oldStyleValuesprotected java.awt.ColorplaceholderForegroundprotected booleanshowClearButtonprotected javax.swing.JComponenttrailingComponentprotected javax.swing.IcontrailingIcon
-
Constructor Summary
Constructors Constructor Description FlatTextFieldUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.awt.DimensionapplyExtraSize(java.awt.Dimension size)private java.awt.DimensionapplyMinimumWidth(javax.swing.JComponent c, java.awt.Dimension size, int minimumWidth)protected voidapplyStyle(java.lang.Object style)protected java.lang.ObjectapplyStyleProperty(java.lang.String key, java.lang.Object value)protected voidclearButtonClicked()protected javax.swing.text.CaretcreateCaret()protected javax.swing.JComponentcreateClearButton()static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)protected voiddocumentChanged(javax.swing.event.DocumentEvent e)(package private) static java.awt.ColorgetBackground(javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)protected java.awt.RectanglegetIconsRect()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 intgetLeadingIconWidth()java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)protected java.awt.InsetsgetPadding()java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)java.util.Map<java.lang.String,java.lang.Class<?>>getStyleableInfos(javax.swing.JComponent c)java.lang.ObjectgetStyleableValue(javax.swing.JComponent c, java.lang.String key)(package private) java.lang.StringgetStyleType()protected javax.swing.JComponent[]getTrailingComponents()Returns components placed at the trailing side of the text field.protected intgetTrailingIconWidth()protected java.awt.RectanglegetVisibleEditorRect()Returns the rectangle used for the root view of the text.(package private) static booleanhasDefaultMargins(javax.swing.JComponent c, java.awt.Insets defaultMargin)protected booleanhasLeadingIcon()protected booleanhasTrailingIcon()protected voidinstallClearButton()protected voidinstallDefaults()protected voidinstallDocumentListener()protected voidinstallLayout()protected voidinstallLeadingComponent()protected voidinstallListeners()protected voidinstallStyle()protected voidinstallTrailingComponent()voidinstallUI(javax.swing.JComponent c)private voidinstallUIImpl(javax.swing.JComponent c)(package private) booleanisLeftToRight()protected voidpaintBackground(java.awt.Graphics g)(package private) static voidpaintBackground(java.awt.Graphics g, javax.swing.text.JTextComponent c, java.awt.Color focusedBackground)protected voidpaintIcons(java.awt.Graphics g, java.awt.Rectangle r)Paints the leading and trailing icons in the given rectangle.protected voidpaintPlaceholder(java.awt.Graphics g)protected voidpaintSafely(java.awt.Graphics g)protected voidprepareLeadingOrTrailingComponent(javax.swing.JComponent c)protected voidpropertyChange(java.beans.PropertyChangeEvent e)protected voidscrollCaretToVisible()protected voiduninstallClearButton()protected voiduninstallDefaults()protected voiduninstallLeadingComponent()protected voiduninstallListeners()protected voiduninstallTrailingComponent()voiduninstallUI(javax.swing.JComponent c)private voidupdateBackground()(package private) static voidupdateBackground(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 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
-
-
-
-
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:
installUIin classjavax.swing.plaf.basic.BasicTextUI
-
installUIImpl
private void installUIImpl(javax.swing.JComponent c)
-
uninstallUI
public void uninstallUI(javax.swing.JComponent c)
- Overrides:
uninstallUIin classjavax.swing.plaf.basic.BasicTextUI
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaultsin classjavax.swing.plaf.basic.BasicTextUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaultsin classjavax.swing.plaf.basic.BasicTextUI
-
installListeners
protected void installListeners()
- Overrides:
installListenersin classjavax.swing.plaf.basic.BasicTextUI
-
uninstallListeners
protected void uninstallListeners()
- Overrides:
uninstallListenersin classjavax.swing.plaf.basic.BasicTextUI
-
createCaret
protected javax.swing.text.Caret createCaret()
- Overrides:
createCaretin classjavax.swing.plaf.basic.BasicTextUI
-
propertyChange
protected void propertyChange(java.beans.PropertyChangeEvent e)
- Overrides:
propertyChangein 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:
getStyleableInfosin interfaceFlatStylingSupport.StyleableUI- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)- Specified by:
getStyleableValuein 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:
paintSafelyin classjavax.swing.plaf.basic.BasicTextUI
-
paintBackground
protected void paintBackground(java.awt.Graphics g)
- Overrides:
paintBackgroundin 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:
getPreferredSizein classjavax.swing.plaf.basic.BasicTextUI
-
getMinimumSize
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
- Overrides:
getMinimumSizein 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:
getVisibleEditorRectin 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 returnstrailingComponentandclearButton.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
-
-