.. | .. |
---|
1 | | -/* |
---|
2 | | - * To change this template, choose Tools | Templates |
---|
3 | | - * and open the template in the editor. |
---|
4 | | - */ |
---|
5 | 1 | |
---|
6 | | -/** |
---|
7 | | - * |
---|
8 | | - * @author nbriere |
---|
9 | | - */ |
---|
| 2 | +import javax.swing.ImageIcon; |
---|
| 3 | + |
---|
10 | 4 | public class cCheckBox extends javax.swing.JCheckBox |
---|
11 | 5 | { |
---|
12 | 6 | cCheckBox(String name, boolean enabled) |
---|
13 | 7 | { |
---|
14 | 8 | super(name, enabled); |
---|
15 | | - |
---|
16 | | - setBorder(new javax.swing.border.EmptyBorder(0,0,0,0)); |
---|
| 9 | + |
---|
| 10 | + setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0)); |
---|
17 | 11 | //setBorder(new javax.swing.border.EtchedBorder()); |
---|
18 | 12 | } |
---|
| 13 | + |
---|
| 14 | + cCheckBox(ImageIcon icon, boolean enabled) |
---|
| 15 | + { |
---|
| 16 | + super("", enabled); |
---|
| 17 | + |
---|
| 18 | + this.image = icon.getImage(); |
---|
| 19 | + iconWidth = icon.getIconWidth(); |
---|
| 20 | + |
---|
| 21 | + setBorder(new javax.swing.border.EmptyBorder(8, 0, 8, 24)); // top, left, bottom, right |
---|
| 22 | + //setBorder(new javax.swing.border.EtchedBorder()); |
---|
| 23 | + } |
---|
| 24 | + |
---|
| 25 | + private java.awt.Image image; |
---|
| 26 | + private int iconWidth; |
---|
| 27 | + |
---|
| 28 | + @Override |
---|
| 29 | + protected void paintComponent(java.awt.Graphics g) |
---|
| 30 | + { |
---|
| 31 | + super.paintComponent(g); |
---|
| 32 | + if (image != null) |
---|
| 33 | + { |
---|
| 34 | + //if (getWidth() > image.getWidth(null) + 8) |
---|
| 35 | + { |
---|
| 36 | + g.drawImage(image, 18, 6, this); |
---|
| 37 | + } |
---|
| 38 | + } |
---|
| 39 | + } |
---|
19 | 40 | } |
---|