From f88fdb950e913c3652579533976f61722b3b5d6a Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 8 Jan 2025 11:53:37 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-20301=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=83=A8=E5=88=86UI=E4=B8=8D=E6=94=AF=E6=8C=81=E8=BF=90?= =?UTF-8?q?=E5=8A=A8=E4=B8=AD=E7=82=B9=E5=87=BB=E5=AF=BC=E8=87=B4UI?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BD=93=E6=84=9F=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ibutton/UICombinationButton.java | 38 ++++++++----------- .../main/java/com/fr/start/MainDesigner.java | 5 +-- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java index ad9151fdbc..e43e4f48df 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java @@ -3,8 +3,7 @@ package com.fr.design.gui.ibutton; import javax.swing.Icon; import javax.swing.JPanel; import java.awt.BorderLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.event.ActionEvent; import java.util.function.Consumer; import static com.fine.theme.utils.FineClientProperties.BUTTON_BORDER; @@ -33,8 +32,8 @@ public class UICombinationButton extends JPanel { protected UIButton rightButton; - private Consumer leftClickLister; - private Consumer rightClickLister; + private Consumer leftClickLister; + private Consumer rightClickLister; protected void leftButtonClickEvent() { // 左边按钮点击事件 @@ -54,7 +53,7 @@ public class UICombinationButton extends JPanel { * * @param lister 监听 */ - public void addLeftClickLister(Consumer lister) { + public void addLeftActionListener(Consumer lister) { this.leftClickLister = lister; } @@ -63,7 +62,7 @@ public class UICombinationButton extends JPanel { * * @param lister 监听 */ - public void addRightClickLister(Consumer lister) { + public void addRightActionListener(Consumer lister) { this.rightClickLister = lister; } @@ -73,25 +72,18 @@ public class UICombinationButton extends JPanel { leftButton.putClientProperty(BUTTON_BORDER, BUTTON_BORDER_LEFT_ROUND_RECT); rightButton = right; rightButton.putClientProperty(BUTTON_BORDER, BUTTON_BORDER_RIGHT_ROUND_RECT); - leftButton.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (leftClickLister != null) { - leftClickLister.accept(e); - } else { - leftButtonClickEvent(); - } + leftButton.addActionListener(e -> { + if (leftClickLister != null) { + leftClickLister.accept(e); + } else { + leftButtonClickEvent(); } }); - rightButton.addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - if (rightClickLister != null) { - rightClickLister.accept(e); - } else { - rightButtonClickEvent(); - } + rightButton.addActionListener(e -> { + if (rightClickLister != null) { + rightClickLister.accept(e); + } else { + rightButtonClickEvent(); } }); diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 18d1aab0a4..17595c25bb 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -22,7 +22,6 @@ import com.fr.design.fun.MenuHandler; import com.fr.design.fun.OemProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UICombinationButton; -import com.fr.design.gui.ibutton.UISaveForbiddenButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.i18n.Toolkit; @@ -339,14 +338,14 @@ public class MainDesigner extends BaseDesigner { private UICombinationButton createRunButton() { run = new UICombinationButton(new UIButton(Toolkit.i18nText("Fine-Design_Basic_Preview"), new LazyIcon("run").white()), new UIButton(new LazyIcon("triangle_down").white())); - run.addLeftClickLister(mouseEvent -> { + run.addLeftActionListener(event -> { JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null || jt.isSaving()) { return; } WebPreviewUtils.preview(jt); }); - run.addRightClickLister(mouseEvent -> { + run.addRightActionListener(event -> { final JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return;