Browse Source

改一下label 继承 下actionlabel

bugfix/10.0
XiaXiang 6 years ago
parent
commit
bfb5abfc0d
  1. 86
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  3. 32
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

86
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java

@ -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;
}
}

2
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

32
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();
}
}
}
}
Loading…
Cancel
Save