From bfb5abfc0db3684895511452123d9c991a8ae0e4 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 16:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8Blabel=20=E7=BB=A7?= =?UTF-8?q?=E6=89=BF=20=E4=B8=8Bactionlabel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/vcs/ui/ActionLabel.java | 86 ------------------- .../mainframe/vcs/ui/FileVersionDialog.java | 2 +- .../fr/design/mainframe/vcs/ui/VcsLabel.java | 32 +++++++ 3 files changed, 33 insertions(+), 87 deletions(-) delete mode 100755 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java create mode 100755 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java deleted file mode 100755 index eb9f2ddba..000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.fr.design.mainframe.vcs.ui; - -import com.fr.design.gui.ilable.UILabel; - -import javax.swing.event.MouseInputAdapter; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; - -/** - * Created by XiaXiang on 2019/5/15. - */ -public class ActionLabel extends UILabel { - private ActionListener actionListener; - private Color color; - - private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { - public void mouseClicked(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - //Action. - if (actionListener != null) { - ActionEvent actionEvent = new ActionEvent(source, 99, ""); - actionListener.actionPerformed(actionEvent); - } - } - } - - public void mouseEntered(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - - public void mouseExited(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - } - - public void mouseDragged(MouseEvent e) { - } - - public void mouseMoved(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - }; - - public ActionLabel(String text, Color color) { - super(text); - - this.color = color; - this.setForeground(color); - this.addMouseListener(mouseInputAdapter); - this.addMouseMotionListener(mouseInputAdapter); - } - - public void addActionListener(ActionListener actionListener) { - this.actionListener = actionListener; - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - this.color = color; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 96232b7bc..15d8bae63 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -78,7 +78,7 @@ public class FileVersionDialog extends UIDialog { FileVersionDialog.this.setVisible(false); } }); - ActionLabel resetLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR); + VcsLabel resetLabel = new VcsLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR); resetLabel.setBorder(BorderFactory.createEmptyBorder(10, 160, 0, 10)); resetLabel.addActionListener(new ActionListener() { @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java new file mode 100755 index 000000000..a0180a137 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java @@ -0,0 +1,32 @@ +package com.fr.design.mainframe.vcs.ui; + + +import com.fr.design.gui.ilable.ActionLabel; +import com.fr.design.gui.ilable.UILabel; + +import java.awt.Color; +import java.awt.Graphics; + +/** + * Created by XiaXiang on 2019/5/15. + */ +public class VcsLabel extends ActionLabel { + + + public VcsLabel(String text, Color color) { + super(text); + this.setForeground(color); + } + + public void paintComponent(Graphics g) { + if (ui != null) { + Graphics scratchGraphics = (g == null) ? null : g.create(); + try { + ui.update(scratchGraphics, this); + } + finally { + scratchGraphics.dispose(); + } + } + } +} \ No newline at end of file