From 5cb91f8270f1590d3b0112aa2aaacfd7c2492e18 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 4 Apr 2023 14:03:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-90581=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8B=E4=BB=B6=E8=8F=9C=E5=8D=95=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=85=85=E6=BB=A1=EF=BC=8C=E5=AD=98=E5=9C=A8=E7=95=99?= =?UTF-8?q?=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controlpane/UIListGroupControlPane.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java index 890d56da66..47581fb626 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java @@ -139,7 +139,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li } this.checkButtonEnabled(); refreshEventListWrapperPane(); - this.checkGroupPaneSize(); + this.updateGroupPaneSize(contentPane); isPopulating = false; } @@ -207,7 +207,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li nameEdList.addModNameActionListener(new ModNameActionListener() { @Override public void nameModed(int index, String oldName, String newName) { - checkGroupPaneSize(); + updateGroupPaneSize(contentPane); saveSettings(); } }); @@ -297,24 +297,30 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li public void onAddItem(NameableCreator creator) { updateSelectedNameList(creator); getCommonHandlers().onAddItem(creator); - checkGroupPaneSize(); + updateGroupPaneSize(contentPane); } @Override public void onRemoveItem() { getCommonHandlers().onRemoveItem(); refreshEventListWrapperPane(); - checkGroupPaneSize(); + updateGroupPaneSize(contentPane); } @Override public void onCopyItem() { getCommonHandlers().onCopyItem(); - checkGroupPaneSize(); + updateGroupPaneSize(contentPane); } - private void checkGroupPaneSize() { + /** + * 根据父面板更新对应的面板宽度 + * (如果小于父面板的宽度就填充到与父面板宽度一致) + * + * @param parentPane 父面板 + */ + private void updateGroupPaneSize(JPanel parentPane) { int width = 180; Iterator> iterator = nameEdListMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -324,14 +330,14 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont()))); } iterator = nameEdListMap.entrySet().iterator(); - width += 30; + //contentPane是外层的Panel,如果不进行判断的话宽度就可能会小于contentPanel,右侧会有空隙 + //所以需要判断一下,如果外层比较宽就取外层的宽度,防止空隙出现 + width = Math.max(width + 30, parentPane == null ? 0 : parentPane.getWidth()); while (iterator.hasNext()) { Map.Entry entry = iterator.next(); ListWrapperPane wrapperPane = entry.getValue(); UIList uiList = wrapperPane.getNameEdList(); - //contentPane是外层的Panel,如果不进行判断的话宽度就可能会小于contentPanel,右侧会有空隙 - //所以需要判断一下,如果外层比较宽就取外层的宽度,防止空隙出现 - uiList.setFixedCellWidth(Math.max(width, contentPane == null ? 0 : contentPane.getWidth())); + uiList.setFixedCellWidth(width); } }