diff options
author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-25 19:16:37 +0000 |
---|---|---|
committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-25 19:16:37 +0000 |
commit | 4822767988a27366c9905deb4663e5aa7a7824e3 (patch) | |
tree | ca5e4d9beab23d0d466487b39bedcfec34c260b7 /java | |
parent | 91a45b4d45b8c275f6406a50e6621e8a5989f214 (diff) | |
download | ATCD-4822767988a27366c9905deb4663e5aa7a7824e3.tar.gz |
Fixed a small bug. When no image is selected and the user clicks on the canvas,
mouseDown gets called. I wasn't checking to see if the image is not null and
still checking if the mouse was clicked within the bounds of the image.
Diffstat (limited to 'java')
-rw-r--r-- | java/ImageProcessing/framework/ImageCanvas.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/java/ImageProcessing/framework/ImageCanvas.java b/java/ImageProcessing/framework/ImageCanvas.java index f527accf545..182bd54bf9b 100644 --- a/java/ImageProcessing/framework/ImageCanvas.java +++ b/java/ImageProcessing/framework/ImageCanvas.java @@ -143,10 +143,13 @@ class ImageCanvas extends Canvas // Check if mouse is within the bounds of the image private boolean inBounds (int x, int y) { - return (x >= this.x_) && - (y >= this.y_) && - (x <= (this.x_ + this.zoom_ * this.image_.getWidth (this))) && - (y <= (this.y_ + this.zoom_ * this.image_.getHeight (this))); + if (this.image_ == null) + return false; + else + return (x >= this.x_) && + (y >= this.y_) && + (x <= (this.x_ + this.zoom_ * this.image_.getWidth (this))) && + (y <= (this.y_ + this.zoom_ * this.image_.getHeight (this))); } private MediaTracker tracker_ = new MediaTracker(this); |