Results 1 to 2 of 2
- 08-02-2010, 09:11 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 8
- Rep Power
- 0
how to get the "filled size" of a TextArea
Hello
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
PeterLast edited by peterme; 08-03-2010 at 04:17 AM. Reason: better understandable
- 08-06-2010, 09:26 PM #2
Member
- Join Date
- Jan 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
How to set TextArea after getting it's value from CGI script
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-25-2010, 10:53 AM -
Help with vector and textarea
By Antonioj1015 in forum Java AppletsReplies: 2Last Post: 10-14-2009, 10:10 PM -
Setting frame size to the size of an image
By Yoruichi in forum AWT / SwingReplies: 5Last Post: 04-22-2009, 05:37 PM -
TextArea Bug?
By Soda in forum New To JavaReplies: 2Last Post: 12-07-2007, 01:37 PM -
textarea
By ubuntu in forum AWT / SwingReplies: 4Last Post: 05-12-2007, 10:54 PM
Bookmarks