aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with frame size" Watch "problem with frame size" New topic
Author

problem with frame size

Arun Bhowmick
Greenhorn

Joined: Aug 19, 2003
Posts: 7
hi,
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
Greenhorn

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"
Sheriff

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


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

Joined: Aug 19, 2003
Posts: 20
hi,
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
, Image.SCALE_DEFAULT);
} else if (wid > iWidth && het < iHeight){
resizedImage = i.getScaledInstance(iWidth, het
, Image.SCALE_DEFAULT);
} else {
resizedImage = i.getScaledInstance(wid, het
, Image.SCALE_DEFAULT);
}

} catch (Exception e) {
e.printStackTrace();
}
return resizedImage;
}
Now add the resized image to your frame.
And do let me knw if it helped.
Shelly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with frame size
 
Similar Threads
An HTML page
jar size
2d Scrolling
panning a large image
Can we resize the image in j2me