Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

increase size of scrollpane at run time

 
khushbushah shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a lot depends on the layoutManager used for the scrollPane's parent
 
khushbushah shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using BorderLayout()
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why don't you just use a TextArea - it will scroll to the bottom automatically
 
khushbushah shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic