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 6da8957b26..c6a86de53d 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;