.. | .. |
---|
2 | 2 | |
---|
3 | 3 | public class cLabel extends javax.swing.JLabel |
---|
4 | 4 | { |
---|
| 5 | + boolean fit; |
---|
| 6 | + |
---|
5 | 7 | BufferedImage image; |
---|
6 | 8 | |
---|
7 | 9 | cLabel(String name) |
---|
.. | .. |
---|
55 | 57 | } |
---|
56 | 58 | else |
---|
57 | 59 | { |
---|
58 | | - BufferedImage resizedimage = new BufferedImage(getWidth(),getHeight(),java.awt.image.BufferedImage.TYPE_INT_RGB); |
---|
| 60 | + BufferedImage resizedimage = new BufferedImage(getWidth(),getHeight(),java.awt.image.BufferedImage.TYPE_INT_ARGB); |
---|
59 | 61 | java.awt.Graphics2D g2 = resizedimage.createGraphics(); |
---|
60 | 62 | g2.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION, java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
61 | | - g2.drawImage(image, 0, 0,getWidth(),getHeight(), null); |
---|
| 63 | + |
---|
| 64 | + if (fit) |
---|
| 65 | + g2.drawImage(image, 0, 0, getWidth(), getHeight(), null); |
---|
| 66 | + else |
---|
| 67 | + { |
---|
| 68 | + g2.drawImage(image, getWidth()/2 - image.getWidth()/2, 0, image.getWidth(), image.getHeight(), null); |
---|
| 69 | + } |
---|
| 70 | + |
---|
62 | 71 | g2.dispose(); |
---|
63 | 72 | |
---|
64 | 73 | g.drawImage(resizedimage, 0, 0,getWidth(),getHeight(), null); |
---|