• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to dynamic set JTextPane height??

 
chester lin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic