aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/PicHelper/ImagePanel.java
diff options
context:
space:
mode:
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) {