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 JTextArea and scrolling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea and scrolling" Watch "JTextArea and scrolling" New topic
Author

JTextArea and scrolling

Vinod Kumar
Greenhorn

Joined: Jan 22, 2002
Posts: 10
Hello,
I have the following code to make my JTextArea scroll, but it isn't. It is connected to a JScrollPane, but it isn't scrolling. I can see the scroll bar to the right of the text area, but the scroll bar is empty, it just has the two arrows at the top and bottom, but no scroller thing. The Text area and scroll bar seem to be not associated in any way. Here is my code:

What's the problem?
Any help is greatly appreciated.
Vinu
[ February 09, 2002: Message edited by: Vinu Murugesan ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

One thing wrong with your code is that you are adding both the text area and the ScrollPane. You only need to add the scroll pane. It contains your text area.
If there is no text in a text area, then there is nothing to scroll. Try filling the textArea with text that goes beyond the boundries and I bet your scrolling bar will show up. If you reply to this post again, notice the scroll bar to the right of what you typing right now. It is set up the same way.
[ February 09, 2002: Message edited by: Gregg Bolinger ]

GenRocket - A Test Data Generation Platform
Vinod Kumar
Greenhorn

Joined: Jan 22, 2002
Posts: 10
Thank you so much!
After I removed the JTextArea from the panel it worked. Now I know that you should add only the JScrollPane.
Thanks again,
Vinu.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea and scrolling
 
Similar Threads
How to work with a ScrollPane in a SplitPane?
jpane with scrollpane is not displaying
Adding ScrollBar to JTextArea
How to Resize JScrollPane used in a JPanel?
Why aren't my components wrapping?