File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Setting ScrollPane 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 "Setting ScrollPane size" Watch "Setting ScrollPane size" New topic
Author

Setting ScrollPane size

Tom Sullivan
Ranch Hand

Joined: Dec 20, 2005
Posts: 72
I don't know if this belongs here or under Other API's. Sorry if this is the wrong forum.

I am learing JAI right now. That is the purpose of the following code. Please ignore the fact that I am turning something into a ByteArraySeekableStream when I really don't have to. I did that to see what to expect when my server socket sends down multi-page ByteArraySeekableStreams (I wanted to know if JAI could tell where one page starts and another begins with such a stream). The same is true for why I turn a RenderedImage to a PlanarImage (I am just testing and figuring out here).

Now I am trying to learn how to use the ScrollPane to work with the images I build. I have done several things trying to get ScrollPane to set its size to other than the size of the image. The convoluted code below just arbitrarily tries to set it to half the size of the image. But, it always grows to the size of the image no matter how I try to go about making its size static.



What I get when I run above is all images of my multipage tiff loaded in individual scrollpanes that are as large as the images. Can someone give me some feedback that may solve my problem?
Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
Hi,

Instead of using setSize function use setPrefferedSize() and see if it works....

scrollPane.setPrefferedSize(new Dimension(sizex/2,sizey/2));


~ Anand,
SCJP 1.5
SCWCD 1.5
Tom Sullivan
Ranch Hand

Joined: Dec 20, 2005
Posts: 72
That was easy. Thanks for the response. Works like it is supposed to now!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting ScrollPane size
 
Similar Threads
Image not getting painted.
Java Advanced Imaging
JAI blurry images
BMP compression in JAI
JAI - creating multi page tiff images