Results 1 to 2 of 2
  1. #1
    peterme is offline Member
    Join Date
    Jan 2010
    Rep Power

    Question 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
    Last edited by peterme; 08-03-2010 at 04:17 AM. Reason: better understandable

  2. #2
    peterme is offline Member
    Join Date
    Jan 2010
    Rep Power

Similar Threads

  1. Replies: 1
    Last Post: 05-25-2010, 10:53 AM
  2. Help with vector and textarea
    By Antonioj1015 in forum Java Applets
    Replies: 2
    Last Post: 10-14-2009, 10:10 PM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 05:37 PM
  4. TextArea Bug?
    By Soda in forum New To Java
    Replies: 2
    Last Post: 12-07-2007, 01:37 PM
  5. textarea
    By ubuntu in forum AWT / Swing
    Replies: 4
    Last Post: 05-12-2007, 10:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts