How to determine text fit in JTextArea/JTextPane ?

I am given a fixed size of JTextArea/JTextPane, and I want to know if a text that is wrapped in the text component is able to fit into Text component given a certain font size. That is able to show the whole text without scrolling.

If text is shown requiring scrolling then return true, else false.

What java code can do that ? I want to alter the font size of text so that the auto-wrapped text can fix into the text component without scrolling.

thanx

[477 byte] By [Macewa] at [2007-11-26 22:48:22]
# 1
just call the component's getPreferredSize() and I think that should return the wanted size
Nethera at 2007-7-10 12:08:06 > top of Java-index,Desktop,Core GUI APIs...