aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes increase size of scrollpane at run time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "increase size of scrollpane at run time" Watch "increase size of scrollpane at run time" New topic
Author

increase size of scrollpane at run time

khushbushah shah
Greenhorn

Joined: Jun 25, 2012
Posts: 10
hi,

How can i increase size of scrollpane at run time?

i have try scrollpane.setMaximumSize(new Dimension(nw,nh));
but its not working for me....

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
a lot depends on the layoutManager used for the scrollPane's parent
khushbushah shah
Greenhorn

Joined: Jun 25, 2012
Posts: 10
I am using BorderLayout()
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
there are many restrictions in BorderLayout, rather than going through them one at a time,
copy your code into another .java file, strip everything unrelated to displaying the scrollpane,
make sure it compiles/runs and post that code. also advise the new size you want it to be.
khushbushah shah
Greenhorn

Joined: Jun 25, 2012
Posts: 10
Hi Michael,

I have add a comment in code from where you have to increase scrollpane height.


here is the code



also i don't want horizontal scroll.

Thank you for replying.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
adding the scrollpane to the applet's 'center' means it will occupy all available space,
i.e. after north,south,east,west considerations. as there's nothing in the other areas, it will
take up all space, meaning you can do nothing with it's size.

make this change, and the panel will take all the extra space



that will give you a scrollpane you can resize, but your code makes very little sense to me

> this.setSize(nw, nh);
> /// Here i want to increase size of Scrollpane - object is owner.s
> /// and new height is nh

you're increasing the size of the canvas - this.setSize(nw, nh);
and now you want to increase the height of the scrollpane to the same as the canvas,
with the added "also i don't want horizontal scroll. "

so, the question is - why use a scrollpane at all? (it can't possibly scroll)
khushbushah shah
Greenhorn

Joined: Jun 25, 2012
Posts: 10
the problem is :
after writing string using drawstring() at last line in canvas, I want to increase height(let's say height + 160) so that Content of canvas retain and i can also add new content.

for that i am resizing canvas using (keyDown() method)




now canvas height is increased but still i can't see the content which i printed after resizing. for that i have to re-size the window(using mouse i increase applet window size).
so i thought scrollpane is not invalidate by just calling srollpane.invalidate() method.

beacuse of this i think of resizing scrollpane height.


and after resizing previous content is also not retain on page. beacuse of
buffImage = this.createImage(nw, nh); (in initPaint() method).




Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
why don't you just use a TextArea - it will scroll to the bottom automatically
khushbushah shah
Greenhorn

Joined: Jun 25, 2012
Posts: 10
Actually code is already developed by other i only need to add scroll bar.

so is it possible or not ? if yes can you give me hint where am i wrong?
or i must have to use textarea?

I also want to display high lighted or bold text? is it possible in textarea?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: increase size of scrollpane at run time