From 6d2f45cd04d5f40babadcf7ae428afde767f563c Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 4 Sep 2021 15:49:15 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58589=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=BE=88=E5=A4=9A=E6=97=B6=EF=BC=8C=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=A0=B7=E5=BC=8F=E4=BB=A5=E5=90=8E=E4=BC=9A?= =?UTF-8?q?=E6=A6=82=E7=8E=87=E9=81=87=E5=88=B0=E6=A0=B7=E5=BC=8F=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=80=89=E4=B8=AD=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 偶尔会出现点击手势回调在选中前执行,导致获取到的被选中样式是错误的。 使用新的列表项选中监听方法 【改动思路】 同上 --- .../style/ThemedCellStyleListPane.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java index eb6f5484e..53fe811db 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java @@ -22,11 +22,11 @@ import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.io.Serializable; import java.util.List; @@ -44,21 +44,17 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane imp styleList.setCellRenderer(new RadioButtonListCellRenderer()); styleList.setOpaque(false); styleList.setBackground(null); - setLayout(FRGUIPaneFactory.createBorderLayout()); - add(styleList, BorderLayout.CENTER); - setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER)); - - styleList.addMouseListener(new MouseAdapter() { + styleList.addListSelectionListener(new ListSelectionListener() { @Override - public void mouseClicked(MouseEvent e) { - int clickedNumber = e.getClickCount(); - if (clickedNumber == 1) { - if (changeListener != null) { - changeListener.stateChanged(new ChangeEvent(styleList)); - } + public void valueChanged(ListSelectionEvent e) { + if (changeListener != null) { + changeListener.stateChanged(new ChangeEvent(styleList)); } } }); + setLayout(FRGUIPaneFactory.createBorderLayout()); + add(styleList, BorderLayout.CENTER); + setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER)); DesignerContext.setDesignerBean("predefinedStyle", this); }