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 Colorprivate AtomicBooleanprotected Stringprotected Colorprotected booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprivate Insetsprotected Colorprotected Colorprivate booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprivate Iconprivate booleanprotected Colorprotected Colorprivate static Rectangleprotected intprotected intprotected intprotected booleanprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected intprivate final booleanprotected booleanprotected Colorprivate static Rectangleprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Colorprotected Color(package private) static final int(package private) static final int(package private) static final intprivate static RectangleFields 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 ComponentUIprivate intprotected Colorprotected ColorgetBackgroundBase(JComponent c, boolean def) intgetBaseline(JComponent c, int width, int height) (package private) static intgetBaselineImpl(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 Stringprotected Colorprotected ColorgetForegroundBase(JComponent c, boolean def) getStyleableValue(JComponent c, String key) (package private) Stringprivate booleanprotected voidprotected voidprotected voidvoidprivate void(package private) static boolean(package private) static booleanprotected booleanprotected boolean(package private) static booleanstatic boolean(package private) static boolean(package private) static booleanReturns 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 booleanprivate static Stringlayout(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.voidpaint(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
-
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:
installUIin classBasicButtonUI
-
installUIImpl
-
installDefaults
- Overrides:
installDefaultsin classBasicButtonUI
-
uninstallDefaults
- Overrides:
uninstallDefaultsin classBasicButtonUI
-
installListeners
- Overrides:
installListenersin classBasicButtonUI
-
uninstallListeners
- Overrides:
uninstallListenersin classBasicButtonUI
-
createButtonListener
- Overrides:
createButtonListenerin classBasicButtonUI
-
propertyChange
-
installStyle
- Since:
- 2
-
getStyleType
String getStyleType()- 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
-
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:
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
-
defaultBoldPlainWidthDiff
-
hasDefaultMargins
-
getBaseline
- Overrides:
getBaselinein 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
-