From 006ae3f93654c74121787bf120021014d4ce1aa6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 20:34:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55715=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-=E9=A2=9C=E8=89=B2=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E5=92=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=87=8C=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=9C=B0=E6=96=B9=E7=9A=84=E9=A2=9C=E8=89=B2=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E4=B8=8D=E5=A4=AA=E4=B8=80=E6=A0=B7=EF=BC=8C?= =?UTF-8?q?=E7=9C=8B=E8=B5=B7=E6=9D=A5=E6=9C=89=E7=82=B9=E5=A5=87=E6=80=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 新颜色选择框的右侧Button与UIComboBox右侧的Button风格不一致,导致视觉上开起来不和谐; 而且因为因为新颜色选择框右侧Button背景为白色边框为灰色,而UIComboBox边框和背景都为灰色, 所以即使给颜色选择框和UIComboBox相同的宽度,看起来也不没有对齐 【改动思路】 统一下颜色选择框的右侧按钮显示效果,保持与UIComboBox中右侧按钮一致 --- .../fr/design/style/AbstractSelectBox.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java b/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java index 8b727e099..1d66094f1 100644 --- a/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/AbstractSelectBox.java @@ -10,16 +10,20 @@ import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import javax.swing.AbstractButton; import javax.swing.JPanel; import javax.swing.border.AbstractBorder; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; +import javax.swing.plaf.ButtonUI; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.stable.Constants; +import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.style.background.BackgroundJComponent; +import com.fr.stable.Constants; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -29,7 +33,7 @@ import com.fr.design.style.background.BackgroundJComponent; public abstract class AbstractSelectBox extends AbstractPopBox implements MouseListener { private static final long serialVersionUID = 2355250206956896774L; - private UIToggleButton triggleButton; + private UIButton triggleButton; protected void initBox(int preWidth) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -37,8 +41,34 @@ public abstract class AbstractSelectBox extends AbstractPopBox implements Mou displayComponent = new BackgroundJComponent(); displayComponent.setEmptyBackground(); displayComponent.setBorder(new TriggleLineBorder()); - triggleButton = new UIToggleButton(UIConstants.ARROW_DOWN_ICON); + triggleButton = new UIButton(UIConstants.ARROW_DOWN_ICON) { + public boolean shouldResponseChangeListener() { + return false; + } + + @Override + public ButtonUI getUI() { + return new UIButtonUI() { + @Override + protected boolean isPressed(AbstractButton b) { + return model.isArmed() && model.isPressed(); + } + + @Override + protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { + if (isPressed(b) && b.isPressedPainted()) { + GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), UIConstants.COMBOBOX_BTN_PRESS); + } else if (isRollOver(b)) { + GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER); + } else if (b.isNormalPainted()) { + GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL); + } + } + }; + } + }; triggleButton.setPreferredSize(new Dimension(20, 20)); + triggleButton.setRoundBorder(true, Constants.LEFT); JPanel displayPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); displayPane.add(displayComponent, BorderLayout.CENTER);