From e1beb6c99d37059e39feef82776141255958cb70 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 29 Dec 2021 17:57:34 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65124=20=E3=80=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E3=80=91=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E7=BC=96=E8=BE=91=E7=9A=84=E6=95=88=E6=9E=9C=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 虽然ListCellRenderer中去除了icon,但是JNamedList实现还使用了icon的宽度来绘制内容,导致 渲染出来的编辑框有问题 【改动思路】 重新实现一个图表宽度为0的JNamedList --- .../theme/edit/CellStyleListEditPane.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index 0b5c7b61e7..3f198f230a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -30,9 +30,11 @@ import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.ListModel; import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Component; @@ -101,7 +103,7 @@ public class CellStyleListEditPane extends JListControlPane { @Override protected JNameEdList createJNameList() { - JNameEdList nameEdList = super.createJNameList(); + JNameEdList nameEdList = new NoIconNamedList(new DefaultListModel()); nameEdList.setCellEditor(new UnEditableListCellEditor(new UITextField())); nameEdList.setCellRenderer(new NoIconNameableListCellRenderer()); return nameEdList; @@ -294,6 +296,17 @@ public class CellStyleListEditPane extends JListControlPane { return component; } } + private class NoIconNamedList extends JNameEdList { + + public NoIconNamedList(ListModel dataModel) { + super(dataModel); + } + + @Override + public int getIconWidth() { + return 0; + } + } private class UnEditableListCellEditor extends DefaultListCellEditor { public UnEditableListCellEditor(UITextField textField) {