aspose file tools*
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to dynamic set JTextPane height??" Watch "How to dynamic set JTextPane height??" New topic
Author

How to dynamic set JTextPane height??

chester lin
Greenhorn

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
Bartender

Joined: Oct 16, 2003
Posts: 1096
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to dynamic set JTextPane height??