Forums Register Login

Make JTextPane adjust height to content

+Pie Number of slices to send: Send
I have applet in witch is JTextPane, from database reads StyledDocuments.
I'm trying to get a JTextPane to adjust its height according to whatever content I feed it. All I can do is to set a fixed height in pixels using Dimension.

How do I make the JTextPane collapse/expand so it will fit to contents?

+Pie Number of slices to send: Send
Users don't like the size of components to keep changing size. Normally you add the text pane to a JScrollPane and set the preferred size of the scroll pane to be a reasonable size. Then srollbar will appear if necessary. This is the way all applications are designed like you web browser or even this forum. Scroll bars will appear if the text of you question is too long.
+Pie Number of slices to send: Send
 

Milutin Markovic wrote:...
I'm trying to get a JTextPane to adjust its height according to whatever content I feed it. All I can do is to set a fixed height in pixels using Dimension.
...


http://java-sl.com/tip_text_height_measuring.html

Hope this helps.

Regards,
Stas
+Pie Number of slices to send: Send
Thanks Stanislav Lapitsky. You help me a lot.
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6515 times.
Similar Threads
viewports and scrollbars
How to retrieve an icon from JTextPane ??
Setting the width of a JTextPane
How to set layout_height of a spinner in code dynamically
how to print the contents of jtextpane.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:32:09.