Package com.formdev.flatlaf.ui
Class FlatButtonUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ButtonUI
javax.swing.plaf.basic.BasicButtonUI
com.formdev.flatlaf.ui.FlatButtonUI
- All Implemented Interfaces:
FlatStylingSupport.StyleableUI
- Direct Known Subclasses:
FlatToggleButtonUI
Provides the Flat LaF UI delegate for
JButton
.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
private AtomicBoolean
protected String
protected Color
protected boolean
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
private Insets
protected Color
protected Color
private boolean
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
private Icon
private boolean
protected Color
protected Color
private static Rectangle
protected int
protected int
protected int
protected boolean
protected Color
protected Color
protected Color
protected Color
protected Color
protected int
private final boolean
protected boolean
protected Color
private static Rectangle
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
protected Color
(package private) static final int
(package private) static final int
(package private) static final int
private static Rectangle
Fields inherited from class javax.swing.plaf.basic.BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyStyle
(AbstractButton b, Object style) protected Object
applyStyleProperty
(AbstractButton b, String key, Object value) static Color
buttonStateColor
(Component c, Color enabledColor, Color disabledColor, Color focusedColor, Color hoverColor, Color pressedColor) protected BasicButtonListener
static ComponentUI
private int
protected Color
protected Color
getBackgroundBase
(JComponent c, boolean def) int
getBaseline
(JComponent c, int width, int height) (package private) static int
getBaselineImpl
(JComponent c, int width, int height) Similar to BasicButtonUI.getBaseline(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19.(package private) static int
(package private) static String
protected Color
protected Color
getForegroundBase
(JComponent c, boolean def) getStyleableValue
(JComponent c, String key) (package private) String
private boolean
protected void
protected void
void
private void
(package private) static boolean
(package private) static boolean
protected boolean
protected boolean
(package private) static boolean
static boolean
(package private) static boolean
(package private) static boolean
Returns true if the button has an icon but no text, or it does not have an icon and the text is either "..." or one character.(package private) static boolean
private static String
layout
(AbstractButton b, FontMetrics fm, int width, int height) Similar to BasicButtonUI.layout(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19.void
paint
(Graphics g, JComponent c) Similar to BasicButtonUI.paint(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19.protected void
protected void
paintIcon
(Graphics g, JComponent c, Rectangle iconRect) protected void
paintText
(Graphics g, AbstractButton b, Rectangle textRect, String text) static void
protected void
protected void
void
update
(Graphics g, JComponent c) Methods inherited from class javax.swing.plaf.basic.BasicButtonUI
clearTextShiftOffset, getBaselineResizeBehavior, getDefaultTextIconGap, getMaximumSize, getMinimumSize, getPropertyPrefix, getTextShiftOffset, installKeyboardActions, installListeners, paintButtonPressed, paintFocus, paintText, setTextShiftOffset, uninstallKeyboardActions, uninstallListeners, uninstallUI
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
-
Field Details
-
minimumWidth
protected int minimumWidth -
iconTextGap
protected int iconTextGap -
background
-
foreground
-
startBackground
-
endBackground
-
focusedBackground
-
focusedForeground
- Since:
- 2.3
-
hoverBackground
-
hoverForeground
- Since:
- 2.3
-
pressedBackground
-
pressedForeground
- Since:
- 2.3
-
selectedBackground
-
selectedForeground
-
disabledBackground
-
disabledText
-
disabledSelectedBackground
-
disabledSelectedForeground
- Since:
- 2.3
-
defaultBackground
-
defaultEndBackground
-
defaultForeground
-
defaultFocusedBackground
-
defaultFocusedForeground
- Since:
- 2.3
-
defaultHoverBackground
-
defaultHoverForeground
- Since:
- 2.3
-
defaultPressedBackground
-
defaultPressedForeground
- Since:
- 2.3
-
defaultBoldText
protected boolean defaultBoldText -
paintShadow
protected boolean paintShadow -
shadowWidth
protected int shadowWidth -
shadowColor
-
defaultShadowColor
-
toolbarHoverBackground
-
toolbarHoverForeground
- Since:
- 2.3
-
toolbarPressedBackground
-
toolbarPressedForeground
- Since:
- 2.3
-
toolbarSelectedBackground
-
toolbarSelectedForeground
- Since:
- 2.3
-
toolbarDisabledSelectedBackground
- Since:
- 2.3
-
toolbarDisabledSelectedForeground
- Since:
- 2.3
-
buttonType
- Since:
- 2
-
squareSize
protected boolean squareSize- Since:
- 2
-
minimumHeight
protected int minimumHeight- Since:
- 2
-
helpButtonIcon
-
defaultMargin
-
defaults_initialized
private boolean defaults_initialized -
oldStyleValues
-
TYPE_OTHER
static final int TYPE_OTHER- See Also:
-
TYPE_SQUARE
static final int TYPE_SQUARE- See Also:
-
TYPE_ROUND_RECT
static final int TYPE_ROUND_RECT- See Also:
-
viewR
-
textR
-
iconR
-
-
Constructor Details
-
FlatButtonUI
protected FlatButtonUI(boolean shared) - Since:
- 2
-
-
Method Details
-
createUI
-
installUI
- Overrides:
installUI
in classBasicButtonUI
-
installUIImpl
-
installDefaults
- Overrides:
installDefaults
in classBasicButtonUI
-
uninstallDefaults
- Overrides:
uninstallDefaults
in classBasicButtonUI
-
createButtonListener
- Overrides:
createButtonListener
in classBasicButtonUI
-
propertyChange
-
installStyle
- Since:
- 2
-
getStyleType
String getStyleType()- Since:
- 2
-
applyStyle
- Since:
- 2
-
applyStyleProperty
- Since:
- 2
-
getStyleableInfos
- Specified by:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
- Specified by:
getStyleableValue
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2.5
-
isContentAreaFilled
-
isFocusPainted
-
isDefaultButton
-
isIconOnlyOrSingleCharacterButton
Returns true if the button has an icon but no text, or it does not have an icon and the text is either "..." or one character. -
getButtonType
-
isHelpButton
-
isToolBarButton
-
isBorderlessButton
-
getButtonTypeStr
-
update
- Overrides:
update
in classComponentUI
-
paintBackground
-
paint
Similar to BasicButtonUI.paint(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19. See https://github.com/openjdk/jdk/pull/8407 and https://github.com/openjdk/jdk/pull/8407#issuecomment-1761583430- Overrides:
paint
in classBasicButtonUI
-
paintIcon
- Overrides:
paintIcon
in classBasicButtonUI
-
paintText
- Overrides:
paintText
in classBasicButtonUI
-
paintText
public static void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground) -
getBackground
-
getBackgroundBase
-
isCustomBackground
-
buttonStateColor
-
getForeground
-
getForegroundBase
- Since:
- 2.3
-
isCustomForeground
-
getPreferredSize
- Overrides:
getPreferredSize
in classBasicButtonUI
-
defaultBoldPlainWidthDiff
-
hasDefaultMargins
-
getBaseline
- Overrides:
getBaseline
in classBasicButtonUI
-
getBaselineImpl
Similar to BasicButtonUI.getBaseline(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19. See https://github.com/openjdk/jdk/pull/8407 and https://github.com/openjdk/jdk/pull/8407#issuecomment-1761583430 -
layout
Similar to BasicButtonUI.layout(), but does not use zero insets for HTML text, which is done in BasicButtonUI.layout() since Java 19. See https://github.com/openjdk/jdk/pull/8407 and https://github.com/openjdk/jdk/pull/8407#issuecomment-1761583430
-