• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Create images of a JTextPane's content

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!

I have a JTextPane with a lot of content, it's spanning several pages. I would like to make some thumbnail preview of that content. I have all the parameters needed, like the size of the clip of the JTextPane's content for each thumbnail.

As far as I can see, I need to take e.g. a BufferedImage and get that instance's Graphics object, then pass that object to the JTextPane's paint() method, but how do I specify which clip of the JTextPane's content it should render?? I have tried with the g.setClip(), but that only influences the clip of the BufferedImage, not the clip of the JTextPane ... this results in all BufferedImages being all black besides the first one, where the clip is actually inside the renderable area ... argh!





Can anyone guide me in the right direction on this one? I've run out of good ideas myself (besides posting here, of course! )

Thanks in advance!

/janus
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr. Wood,

As usual you're the finest treat in the whole box of chocolates! Thank you very much for your code, which helped me alot!
As you can see in my own code I wasn't that off the solution myself, but the key you provided, the call to translate(x, y), really made my boat rock.

Again, thank you very much!


Regards,
Janus
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic