From da6ad1d677a775eb81df8cd20c66e751c8f95a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Thu, 7 Dec 2023 16:37:48 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-107972=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E7=BF=BB=E6=96=B0-UIComboBox=E7=BF=BB?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/FineRoundBorder.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java new file mode 100644 index 0000000000..280f3ca746 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java @@ -0,0 +1,59 @@ +package com.fine.theme.light.ui; + +import com.formdev.flatlaf.ui.FlatRoundBorder; +import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; +import com.fr.design.event.HoverAware; + +import javax.swing.UIManager; +import java.awt.Color; +import java.awt.Component; +import java.awt.Paint; + + +/** + * 通用的Border类,具备hover、click、禁用等多种状态 + * + * @author Levy.Xie + * @since 11.0 + * Created on 2023/12/06 + */ +public class FineRoundBorder extends FlatRoundBorder { + + @Styleable(dot = true) + protected Color borderColor = UIManager.getColor("defaultBorderColor"); + @Styleable(dot = true) + protected Color disabledBorderColor = UIManager.getColor("defaultBorderColor"); + @Styleable(dot = true) + protected Color highlightBorderColor = UIManager.getColor("defaultHighlightBorderColor"); + @Styleable(dot = true) + protected Color focusColor = UIManager.getColor("defaultBorderFocusShadow"); + @Styleable(dot = true) + protected int focusWidth = UIManager.getInt("defaultBorderFocusWidth"); + + @Override + protected Paint getBorderColor(Component c) { + if (isEnabled(c)) { + if (c instanceof HoverAware && ((HoverAware) c).isHovered()) { + return getHoverBorderColor(); + } else { + return isFocused(c) ? focusedBorderColor : borderColor; + } + } + return disabledBorderColor; + } + + @Override + protected Color getFocusColor(Component c) { + return focusColor; + } + + @Override + protected int getFocusWidth(Component c) { + return focusWidth; + } + + protected Color getHoverBorderColor() { + return highlightBorderColor; + } + +}