Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting the width of a JTextPane  RSS feed

 
Frederick Winsnes
Greenhorn
Posts: 17
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I want to use a JTextPane in which the user should write whatever they want

I would like to have a limited width but an unlimited height on the JTextPane but I can't find a way to do that, so now I am asking:
is there a way to set the width of a JTextPane, inside a layout?

I am using a BorderLayout in the JFrame in which the JTextPane is located.

 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add the JTextPane to a JScrollPane. The text will wrap automatically when the width of the text pane is reached.

If you need more help then post your SSCCE that demonstrates the problem.
 
Frederick Winsnes
Greenhorn
Posts: 17
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Add the JTextPane to a JScrollPane. The text will wrap automatically when the width of the text pane is reached.

If you need more help then post your SSCCE that demonstrates the problem.


Just what I needed!
Thank you very much
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!