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 How to give scrollbars to JTextArea when lines are greater than 3?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to give scrollbars to JTextArea when lines are greater than 3?? " Watch "How to give scrollbars to JTextArea when lines are greater than 3?? " New topic
Author

How to give scrollbars to JTextArea when lines are greater than 3??

umesh kacha
Greenhorn

Joined: Mar 24, 2008
Posts: 12
Hi

I have added one JTextArea inside JScrollPane which is finally inside JPanel

Now based on text/lines inside JTextArea I want that scrollbars must come only if lines are greater than 3

if lines are less than 3 then it should not show scroll bars

Please help

I tried textArea.getLineCount() method but in every case it is returning only 1 as output even if lines are more than 1

In short my problem is that I want to know number of lines a textarea by using which I will set preffered size to JPanel on which I am putting JTextArea

Please help

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

JTextArea has a constructor where you can define the row and column count.
What have you set for setLineWrap and setWrapStyleWord? These booleans will affect the getLineCount


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to give scrollbars to JTextArea when lines are greater than 3??