File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes problem with frame size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with frame size" Watch "problem with frame size" New topic

problem with frame size

Arun Bhowmick

Joined: Aug 19, 2003
Posts: 7
i have a scanned map which i have to put in my frame's background. the size of the image is bigger than the screen size. i need to use this map for some sort of simulation. can anybody help me how can i use this image when part of it outside the screen area?
Manoj kumar A

Joined: Sep 01, 2003
Posts: 10
you can create a class which extends JComponet and overeide paint method.
Inside the paint method use g2D.drawImage(icon.getImage(),x,y,width,height,this);icon object must be crated with the gif or jpg file. the object(of class that extended JComponent) can be added to the JFrame.add(component).
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Moved to the Swing forum.

"JavaRanch, where the deer and the Certified play" - David O'Meara
shelly kalra

Joined: Aug 19, 2003
Posts: 20
i m not to sure, but may be the code is useful to you.
* Resize the image.
*@param original path of image file to be resized.
*@param wid width of the resized image.
*@param het height of the resized image.
*@return Image
public static Image resize(String original, int wid, int het) {
Image resizedImage = null;
try {
File originalFile = new File(original);
ImageIcon ii = new ImageIcon(originalFile.getCanonicalPath());
Image i = ii.getImage();
int iWidth = i.getWidth(null);
int iHeight = i.getHeight(null);
if ((wid > iWidth) && (het > iHeight)) {
return i;

if (wid < iWidth && het > iHeight) {
resizedImage = i.getScaledInstance(wid, iHeight
} else if (wid > iWidth && het < iHeight){
resizedImage = i.getScaledInstance(iWidth, het
} else {
resizedImage = i.getScaledInstance(wid, het

} catch (Exception e) {
return resizedImage;
Now add the resized image to your frame.
And do let me knw if it helped.
I agree. Here's the link:
subject: problem with frame size
It's not a secret anymore!