aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/PicHelper/ImagePanel.java
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2011-09-16 09:15:27 +0100
committerChristopher Baines <cbaines8@gmail.com>2011-09-16 09:15:27 +0100
commitebc965a9f1dc2a1a6aaf66a0c048695eda3a7a25 (patch)
treec6d6106b40c26b08373c7da78aeef0ca3e1575a1 /PunchingBag/src/PicHelper/ImagePanel.java
parentd1da2c2b09f2e4754dc89fdb89bbb1d7cb73e0f0 (diff)
downloadpunchingbag-ebc965a9f1dc2a1a6aaf66a0c048695eda3a7a25.tar
punchingbag-ebc965a9f1dc2a1a6aaf66a0c048695eda3a7a25.tar.gz
Image improvements.
Diffstat (limited to 'PunchingBag/src/PicHelper/ImagePanel.java')
-rw-r--r--PunchingBag/src/PicHelper/ImagePanel.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/PunchingBag/src/PicHelper/ImagePanel.java b/PunchingBag/src/PicHelper/ImagePanel.java
index 099fcb8..0551c27 100644
--- a/PunchingBag/src/PicHelper/ImagePanel.java
+++ b/PunchingBag/src/PicHelper/ImagePanel.java
@@ -67,6 +67,11 @@ public class ImagePanel extends JPanel {
g.drawImage(scaledImage, 0, 0, this);
}
}
+
+ public Dimension getPreferredSize() {
+ setScaledImage();
+ return new Dimension(scaledImage.getWidth(null), scaledImage.getHeight(null));
+ }
private void setScaledImage() {
if (image != null) {
@@ -74,8 +79,8 @@ public class ImagePanel extends JPanel {
// use floats so division below won't round
float iw = imageWidth;
float ih = imageHeight;
- float pw = this.getWidth(); // panel width
- float ph = this.getHeight(); // panel height
+ float pw = super.getWidth(); // panel width
+ float ph = super.getHeight(); // panel height
if (pw < iw || ph < ih) {