wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes How to dynamic set JTextPane height?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to dynamic set JTextPane height??" Watch "How to dynamic set JTextPane height??" New topic

How to dynamic set JTextPane height??

chester lin

Joined: May 15, 2012
Posts: 3
Hello , everyone , I'm use JTextPane to put user type message , i try it , it must to set location(x,y) and size(width,height) , so i need to set dynamic height to JTextPane , i had a fixed width , so width it's ok , but height i don't know how to set , i had google about this topic , i found Short.MAX_VALUE to be JTextPane height, but it's not really height , too bad , have someone to help me?? thanks
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

Height of a component will usually decided by the LayoutManager - you can set a preferredSize, but this will be used only as an hint by the layout managers...
Why do you need to set the height? have you added the text pane to a JScrollPane - this will allow the user to enter as much text and scrollbar will appear automatically if the text exceeds the visible height.

Don't get me started about those stupid light bulbs.
subject: How to dynamic set JTextPane height??
jQuery in Action, 3rd edition