• 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

Figuring out when a JTextComponent is full

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,
I'm trying to figure out how to tell when a JTextComponent is full. I'm trying to set up "pages" so that my users don't have to scroll through their documents, they just "flip" through the pages. Right now I'm allowing the users to change the size of the JEditorpane and it would be kewl if my program could autoresize the pages in response. In particular I'm using a JEditorpane, but I can't seem to tell it to load only enough text to fill up the JEditorpane and nothing more.
If anyone could help me, this would be great. Right now I'm digging through Sun's source trying to figure out how the JScrollbar knows when to become enabled and somehow catching this to tell my program to stop loading text into the JEditorpane, but I'm thinking their might be a better way that I don't know about.
Thanks in advance,
Devin
P.S. If no one can help, and I can figure it out, I'll post my solution.
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getVisibleRect() will return the visible area of the JEditorpane. You can use FontMetrics to calculate how many characters can fit in that area.
 
It's a tiny ad only because the water is so cold.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic