Normand Briere
2019-11-21 ddb10cb84dddfeef1ef9946f2e13cef3c93e6cc4
cCheckBox.java
....@@ -1,19 +1,40 @@
1
-/*
2
- * To change this template, choose Tools | Templates
3
- * and open the template in the editor.
4
- */
51
6
-/**
7
- *
8
- * @author nbriere
9
- */
2
+import javax.swing.ImageIcon;
3
+
104 public class cCheckBox extends javax.swing.JCheckBox
115 {
126 cCheckBox(String name, boolean enabled)
137 {
148 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));
1711 //setBorder(new javax.swing.border.EtchedBorder());
1812 }
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
+ }
1940 }