aspose file tools*
The moose likes Java in General and the fly likes Setting the width of a JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Setting the width of a JTextPane" Watch "Setting the width of a JTextPane" New topic
Author

Setting the width of a JTextPane

Frederick Winsnes
Greenhorn

Joined: Feb 22, 2011
Posts: 17

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

Joined: Jun 13, 2009
Posts: 2183
    
    7
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

Joined: Feb 22, 2011
Posts: 17

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.
 
subject: Setting the width of a JTextPane