From 39fd9ae7e71b41facc712c8e06c4feb39efd4946 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jul 2020 11:57:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-35692=20=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE-=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BAINCH=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/report/UnitFieldPane.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java index 6da8957b2..c6a86de53 100644 --- a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java @@ -52,9 +52,9 @@ public class UnitFieldPane extends JPanel { this.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM")); } - //ajust the heigt of unitLabel. - Dimension unitDimension = new Dimension(this.getPreferredSize().width, - preferredHeight); + //自适应label宽度 + int width = this.getFontMetrics(this.getFont()).stringWidth(this.getText()); + Dimension unitDimension = new Dimension(width, preferredHeight); this.setMinimumSize(unitDimension); this.setMinimumSize(unitDimension); this.setSize(unitDimension); @@ -62,7 +62,8 @@ public class UnitFieldPane extends JPanel { } } - public UnitFieldPane(int unitType) { + public + UnitFieldPane(int unitType) { this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.unitType = unitType;