I have a JTextArea define with 1 row. I have also set its setLineWrap to True. As the user enters data into field I want the textfield to expand from 1 row upto 3 rows as needed, so that I can see all 3 rows at once, which it does. But if the user enters more data and more than 3 rows are needed I want to add scroll bars using JSrollPane. I believe this logic is similiar to most " To: " email address boxes in have seen. Any ideas? Thanks, Craig
Well, one way to do it is that when you get more than 3 items, remove the Textarea from the Panel (whatever that may be), add the TextArea to a JSCrollPane, then add the JScrollPane to the panel where the Textarea was.
Is there a way to count or keep track of the number of rows that are added to the JTextArea? This way I would know when I need to add the scroll bars. Craig
Originally posted by Craig Parsons: Is there a way to count or keep track of the number of rows that are added to the JTextArea? This way I would know when I need to add the scroll bars. Craig
Seems to me like you might want to look into using a JList
I thought about a JList and it will not work for what I need. If I use getRows() I can get the number of rows in my textArea but I'm not sure where in my program i need to check that. In other words when I have a textarea and my words wrap, a new row is added to the textarea. Where or what part of a program controls that? Do I need some sort of listener for that? Craig