Reputation: 15
I'm using this to set the size of my buffered image.
Dimension imgDim = new Dimension(700, 380);
BufferedImage gridImage = new BufferedImage(imgDim.width, imgDim.height,
BufferedImage.TYPE_INT_RGB);
instead of this, I would like to set the size of the image using something like:
Dimension imgDim = d;
BufferedImage gridImage = new BufferedImage(d.width/8, d.height/8,
BufferedImage.TYPE_INT_RGB);
but I'm getting negativeArraySizeException
d
is the dimensions of my JFrame
which I'm getting using getMaximumSize()
method
when I print out the value of d.width/8
its something like 268435455 which I can't make sense of. Is there another way to do this please help
Thank you
Upvotes: 0
Views: 2543
Reputation: 51445
d is the dimensions of my JFrame which I'm getting using
getMaximumSize
() method
You would get d using the getSize
() method after you call the pack
() method or setSize
() method.
Upvotes: 1
Reputation: 717
You should use getSize()
instead of getMaximumSize()
.
If you don't setPreferredSize
for your JFrame
, getMaximumSize()
will return a very big number. See Component.getMaximumSize()
getSize()
returns your JFrame's
current size
Upvotes: 0