This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion 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.

I agree. Here's the link:
subject: How to dynamic set JTextPane height??
It's not a secret anymore!