This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Setting the width of a JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 1788
    
    2
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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Setting the width of a JTextPane
 
Similar Threads
Displaying all of the text in a JTextPane How???
determine with
JTextPane viewable area
viewports and scrollbars
JTable with TextRenderes as TextPane