how to get the "filled size" of a TextArea
I am using JEditorPane (embedded in a JScrollPane) to edit text, and I don't know how to get the value for it's “filled size”. (with filled size I mean the Minimum size to show the Entire text without the need for scrollbars).
One poor solution I found was to insert the TextArea in a JFrame, to use the method pack() on the frame, and then use the getsize() method on the TextArea.
If I use the getsize()-method without pack(), I get the size of the TextArea, irrespective of whether it contains any text or not. (and irrespective of scrollbars used)
But I want to know what its size would be, if I cropped all blank rows to the bottom and blank columns to the right. (= aligning the borders with the margins of the text)
E.g. if the TextArea is empty, it’s filled size is (0,0)
I don't really want to use the pack()-method on the Frame. This only works if the scrollbars aren't needed anyway.
Is there a more elegant solution?
Thanks for your help