Hi,
I have a JTextArea and set its contents dynamically. I need to dynamically change the height of the JTextArea depending on the number of rows of text in it.
I came up with the idea of getting the desired height value by multiplying the row height the number of rows as follows (ta is my JTextArea):
However, the compiler gives the the following error:
[tt]getRowHeight() has protected access in javax.swing.JTextArea[/tt]
Is there a way to obtain the row height, or do I need to come up with a new solution?
I'm using the null layout manager.
Thanks!
I have a JTextArea and set its contents dynamically. I need to dynamically change the height of the JTextArea depending on the number of rows of text in it.
I came up with the idea of getting the desired height value by multiplying the row height the number of rows as follows (ta is my JTextArea):
Code:
ta.setSize(400,ta.getRowHeight() * ta.getRows() );
However, the compiler gives the the following error:
[tt]getRowHeight() has protected access in javax.swing.JTextArea[/tt]
Is there a way to obtain the row height, or do I need to come up with a new solution?
I'm using the null layout manager.
Thanks!