1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.magicproject.clickable.targetable.player;
21
22 import java.awt.Graphics;
23
24 import javax.swing.ImageIcon;
25 import javax.swing.JButton;
26
27 /***
28 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
29 * @since 0.81
30 */
31 public class AvatarButton extends JButton {
32
33 /***
34 * Creates a new instance of JButton2 <br>
35 */
36 public AvatarButton() {
37 super();
38 }
39
40 /***
41 * Set the of this button.
42 *
43 * @param defaultIcon
44 */
45 public void setIcon(ImageIcon defaultIcon) {
46 this.defaultIcon = defaultIcon;
47 }
48
49 @Override
50 protected void paintComponent(Graphics g) {
51 if (defaultIcon != null) {
52 super.paintBorder(g);
53 g.drawImage(defaultIcon.getImage(), 0, 0, getWidth() - 2,
54 getHeight() - 2, this);
55 }
56 }
57
58 private ImageIcon defaultIcon;
59 }