1 package sk.stuba.fiit.foo07.genex.gui;
2
3 import java.awt.Canvas;
4 import java.awt.Color;
5 import java.awt.Graphics;
6
7 import javax.swing.ImageIcon;
8
9 public class IconComponent extends Canvas {
10
11
12
13 private static final long serialVersionUID = 8519335936997621021L;
14 ImageIcon icon;
15
16 public IconComponent() {
17 this.setBackground(new Color(255, 255, 240));
18 }
19
20 public IconComponent(ImageIcon value) {
21 this();
22 icon = value;
23 }
24
25 public void setIcon(ImageIcon icon) {
26 this.icon = icon;
27 }
28
29 @Override
30 public void paint(Graphics g) {
31 super.paint(g);
32
33 if (icon == null)
34 return;
35
36 icon.paintIcon(this, g, 0, 0);
37 }
38 }