From 7daa2f08abb9aa2e296bc4978fc9dcd878977386 Mon Sep 17 00:00:00 2001 From: Hades Date: Thu, 14 Feb 2019 15:49:08 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14465=20=E3=80=9010.0=E5=86=92=E7=83=9F?= =?UTF-8?q?=E3=80=91=20=E6=95=B0=E5=AD=97=E6=8E=A7=E4=BB=B6=E2=80=9C?= =?UTF-8?q?=E5=8F=8C=E7=B2=BE=E5=BA=A6=E5=9E=8B=E2=80=9D=20=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=B1=95=E5=BC=80=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=9C=80?= =?UTF-8?q?=E5=BA=95=E7=AB=AF=E6=96=87=E5=AD=97=E8=A2=AB=E9=81=AE=E6=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ibutton/UIButtonGroup.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java index 752681ef0..624e2e8ee 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -26,6 +26,9 @@ import java.util.List; public class UIButtonGroup extends JPanel implements GlobalNameObserver { private static final long serialVersionUID = 1L; + private static final int TEXT_LENGTH = 3; + private static final int BUTTON_SIZE = 2; + private int currentButtonSize = 0; protected List labelButtonList; protected int selectedIndex = -1; private List objectList;// 起到一个render的作用 @@ -154,6 +157,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { if (!ArrayUtils.isEmpty(objects) && textArray.length == objects.length) { this.objectList = Arrays.asList(objects); } + currentButtonSize = textArray.length; labelButtonList = new ArrayList(textArray.length); this.setLayout(getGridLayout(textArray.length)); this.setBorder(getGroupBorder()); @@ -214,11 +218,20 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { protected void initButton(UIToggleButton labelButton) { labelButton.setBorderPainted(false); + adjustButton(labelButton); UIComponentUtils.setLineWrap(labelButton); labelButtonList.add(labelButton); this.add(labelButton); } + private void adjustButton(UIToggleButton labelButton) { + if (labelButton.getText().length() > TEXT_LENGTH && currentButtonSize > BUTTON_SIZE) { + Dimension dimension = labelButton.getPreferredSize(); + dimension.height <<= 1; + labelButton.setPreferredSize(dimension); + } + } + protected Border getGroupBorder() { return BorderFactory.createEmptyBorder(1, 1, 1, 1); }