.. | .. |
---|
22 | 22 | } |
---|
23 | 23 | } |
---|
24 | 24 | |
---|
25 | | - cButton(javax.swing.ImageIcon icon, boolean border) |
---|
| 25 | + cButton(javax.swing.ImageIcon icon, boolean border, boolean fit) |
---|
26 | 26 | { |
---|
27 | 27 | super(icon); |
---|
28 | 28 | |
---|
29 | | - setMargin(new java.awt.Insets(1, 10, 1, 10)); // ?? |
---|
| 29 | + assert(border); |
---|
| 30 | + |
---|
| 31 | + //setMargin(new java.awt.Insets(1, 10, 1, 10)); // ?? |
---|
| 32 | + |
---|
| 33 | + if (icon != null && fit) |
---|
| 34 | + this.image = icon.getImage(); |
---|
30 | 35 | |
---|
31 | 36 | //result = new JButton( icon ); |
---|
32 | 37 | //result.setBorderPainted( false ); |
---|
.. | .. |
---|
42 | 47 | //setBorder(null); //new javax.swing.border.EmptyBorder(0,0,0,0)); |
---|
43 | 48 | } |
---|
44 | 49 | } |
---|
| 50 | + |
---|
| 51 | + private java.awt.Image image; |
---|
| 52 | + |
---|
| 53 | + //@Override |
---|
| 54 | + protected void paintComponent(java.awt.Graphics g) |
---|
| 55 | + { |
---|
| 56 | + if (image != null) |
---|
| 57 | + { |
---|
| 58 | + //if (getWidth() > image.getWidth(null) + 8) |
---|
| 59 | + { |
---|
| 60 | + g.drawImage(image, 0,0, this.getWidth()-1, this.getHeight()-1, this); |
---|
| 61 | + } |
---|
| 62 | + } |
---|
| 63 | + else |
---|
| 64 | + super.paintComponent(g); |
---|
| 65 | + } |
---|
45 | 66 | } |
---|