Meaningless Drivel is fun!*
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 Android Security Essentials Live Lessons this week in the Android 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: 10171
    
    8

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!]
 
Don't get me started about those stupid light bulbs.
 
subject: How to give scrollbars to JTextArea when lines are greater than 3??
 
Similar Threads
JScrollPane & JPanel dynamic changes
Problem in adding Scroll Bar to JPanel.
Tricky JTextArea problem
how to add image to a scrollbar
JTextArea on JScrollPane