permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Displaying all of the text in a JTextPane How??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying all of the text in a JTextPane How???" Watch "Displaying all of the text in a JTextPane How???" New topic
Author

Displaying all of the text in a JTextPane How???

Lee Barney
Ranch Hand

Joined: May 07, 2003
Posts: 37
I have a JPanel with a BoxLayout that has a series of non-editable JTextPanes in it arranged verically.
I add text programatically to each of the JTextPanes.
I need each of these text panes to show all of the text in them when the window is displayed. Currently only a portion of the text is viewable.
I don't want a scrollPane to solve this.
I could set the preferredSize if I could find out what that size would be without displaying the window to the user???
Any ideas on how to force the containing column JPanel to be bigger and force the textpanes to show all of the text??
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
you can use FontMatrics of TextPane and calculate how much width it takes to display the whole text.furthur u need to some math for getting Preffered size.if you could use word wrap,line wrap..


Sun Certified Java Programmer
Lee Barney
Ranch Hand

Joined: May 07, 2003
Posts: 37
I tried using the fontmetrics as you mentioned. The width of the string I am looking at it 119. The width of the JTextPane is 144 and yet when the string is placed in the JTextPane the line wraps.
???
Any ideas why?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Displaying all of the text in a JTextPane How???
 
Similar Threads
paint JTextPane in java.awt.Rectangle
Force the browser to display the Save dialog box
Reloding JPanel
Manually sizing JScrollPane
Updating a JPanel after change...