• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ScrollPane is not working

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I want to have a text area in east of my form with scroll pane.
Above is a code-clip. All is fine but text area is not showing scroll pane.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The text area should go in the scroll pane. Presently, it's in the panel, which is in the scroll pane.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as i know in JScrollPane constructor we have to pass viewport as for Panel.
That is what i have done.
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of explaining why your code is right, when you have already posted it to say it isn't right, I suggest you should take the advice you were given.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry, i am not ignoring the suggestion and don't mean to say that i am completely right, but instead of adopt the suggestion blindly, i am also interested to know at what point I am wrong so that i can make my concept clear as I am beginner.
And Thank You for Suggestion to You All.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Darryl Burke Thank you vary much.
It will be so nice of you if you can explain why my code was not working.
 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JScrollPane uses the preferred size of the component in its viewport to determine whether or not to show scrollbars. In your case that component is not the JTextArea but the WestWindow with a preferred size of 330x50. That WestWindow contains the JTextArea without scrollbars because you simply never programmed any to be there. If you would not manually set the preferred size the WestWindow would calculate its preferred size from the JTextArea instead.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to what Rob said, if the scroll pane's viewport component implements the Scrollable interface, the scroll pane's layout manager honors the viewport component's preferences in respect of the preferred viewport size, tracking the viewport width/height and the scrollable increments.

JTextArea implements Scrollable. JPanel does not.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic