XiaXiang
6 years ago
3 changed files with 33 additions and 87 deletions
@ -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; |
||||
} |
||||
} |
@ -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…
Reference in new issue