dcsimg
displaying Image with scrollbars
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Calvin_Kim
Posted On:   Tuesday, October 9, 2001 07:04 PM

i would like to add Image into ScrollPane. first i made Panel class which display Image and then add this object into ScrollPane. Although image is larger than size of Panel. scrollbars doesn't appear. when i tried with Label instead of Image, ScrollPane wored well. class ImagePanel extends Panel{ private Image img = null; public ImagePanel(String fileName) { img = Toolkit.getDefaultToolkit().createImage(fileName); } } class ProductFrame extends Frame { public ProductFrame(String fileName) { ImagePanel imgPan = new ImagePanel(fileName); ScrollPane sPan = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); sPan.add(imgPan   More>>


i would like to add Image into ScrollPane.

first i made Panel class which display Image and then add this object into ScrollPane.

Although image is larger than size of Panel. scrollbars doesn't appear.
when i tried with Label instead of Image, ScrollPane wored well.

			
class ImagePanel extends Panel{
private Image img = null;
public ImagePanel(String fileName) {
img = Toolkit.getDefaultToolkit().createImage(fileName);
}
}

class ProductFrame extends Frame {
public ProductFrame(String fileName) {
ImagePanel imgPan = new ImagePanel(fileName);
ScrollPane sPan = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sPan.add(imgPan);
setLayout(null);
add(sPan);
setBounds(100, 100, 800,600);
}
}



Please use html tags to format code blocks.

   <<Less

Re: displaying Image with scrollbars

Posted By:   Nils_Kulk  
Posted On:   Wednesday, October 10, 2001 04:14 AM

Hi,

You should implement the getPreferredSize() and getMinimumSize() methods of the ImagePanel. The Dimension object returned by these should reflect the size of the image.
About | Sitemap | Contact