• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create images of a JTextPane's content

 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!