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??
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
Joined: May 07, 2003
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?