• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Lee Barney
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic