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.
- UiDefault:
- Button.font Font, Button.background Color, Button.foreground Color, Button.border Border, Button.margin Insets, Button.rollover boolean , Button.minimumWidth int, Button.iconTextGap int, Button.startBackground Color optional; if set, a gradient paint is used and Button.background is ignored, Button.endBackground Color optional; if set, a gradient paint is used, Button.focusedBackground Color optional, Button.focusedForeground Color optional, Button.hoverBackground Color optional, Button.hoverForeground Color optional, Button.pressedBackground Color optional, Button.pressedForeground Color optional, Button.selectedBackground Color, Button.selectedForeground Color, Button.disabledBackground Color optional, Button.disabledText Color, Button.disabledSelectedBackground Color, Button.disabledSelectedForeground Color optional, Button.default.background Color, Button.default.startBackground Color optional; if set, a gradient paint is used and Button.default.background is ignored, Button.default.endBackground Color optional; if set, a gradient paint is used, Button.default.foreground Color, Button.default.focusedBackground Color optional, Button.default.focusedForeground Color optional, Button.default.hoverBackground Color optional, Button.default.hoverForeground Color optional, Button.default.pressedBackground Color optional, Button.default.pressedForeground Color optional, Button.default.boldText boolean, Button.paintShadow boolean default is false, Button.shadowWidth int default is 2, Button.shadowColor Color optional, Button.default.shadowColor Color optional, Button.toolbar.spacingInsets Insets, Button.toolbar.hoverBackground Color, Button.toolbar.hoverForeground Color optional, Button.toolbar.pressedBackground Color, Button.toolbar.pressedForeground Color optional, Button.toolbar.selectedBackground Color, Button.toolbar.selectedForeground Color optional, Button.toolbar.disabledSelectedBackground Color optional, Button.toolbar.disabledSelectedForeground Color optional
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Colorprotected Stringprotected Colorprotected booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected intprotected intprotected intprotected booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected intprotected booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected ColorFields inherited from class BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyStyle(AbstractButton b, Object style) protected ObjectapplyStyleProperty(AbstractButton b, String key, Object value) static ColorbuttonStateColor(Component c, Color enabledColor, Color disabledColor, Color focusedColor, Color hoverColor, Color pressedColor) protected BasicButtonListenerstatic ComponentUIprotected Colorprotected ColorgetBackgroundBase(JComponent c, boolean def) intgetBaseline(JComponent c, int width, int height) protected Colorprotected ColorgetForegroundBase(JComponent c, boolean def) getStyleableValue(JComponent c, String key) protected voidprotected voidprotected voidvoidprotected booleanprotected booleanstatic booleanvoidpaint(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 voidprotected voidpaintIcon(Graphics g, JComponent c, Rectangle iconRect) protected voidpaintText(Graphics g, AbstractButton b, Rectangle textRect, String text) static voidprotected voidprotected voidprotected voidvoidupdate(Graphics g, JComponent c) Methods inherited from class BasicButtonUI
clearTextShiftOffset, getBaselineResizeBehavior, getDefaultTextIconGap, getMaximumSize, getMinimumSize, getPropertyPrefix, getTextShiftOffset, installKeyboardActions, paintButtonPressed, paintFocus, paintText, setTextShiftOffset, uninstallKeyboardActions, uninstallUIMethods inherited from class 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
-
-
Constructor Details
-
FlatButtonUI
protected FlatButtonUI(boolean shared) - Since:
- 2
-
-
Method Details
-
createUI
-
installUI
- Overrides:
installUIin classBasicButtonUI
-
installDefaults
- Overrides:
installDefaultsin classBasicButtonUI
-
uninstallDefaults
- Overrides:
uninstallDefaultsin classBasicButtonUI
-
installListeners
- Overrides:
installListenersin classBasicButtonUI
-
uninstallListeners
- Overrides:
uninstallListenersin classBasicButtonUI
-
createButtonListener
- Overrides:
createButtonListenerin classBasicButtonUI
-
propertyChange
-
installStyle
- Since:
- 2
-
applyStyle
- Since:
- 2
-
applyStyleProperty
- Since:
- 2
-
getStyleableInfos
- Specified by:
getStyleableInfosin interfaceFlatStylingSupport.StyleableUI- Since:
- 2
-
getStyleableValue
- Specified by:
getStyleableValuein interfaceFlatStylingSupport.StyleableUI- Since:
- 2.5
-
isFocusPainted
-
update
- Overrides:
updatein 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:
paintin classBasicButtonUI
-
paintIcon
- Overrides:
paintIconin classBasicButtonUI
-
paintText
- Overrides:
paintTextin 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:
getPreferredSizein classBasicButtonUI
-
getBaseline
- Overrides:
getBaselinein classBasicButtonUI
-