• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using PrinterJob to print graphic?

 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

I'm working on an application where I create a graph. The class that paints the graph is defined as following:



I override paintComponent(Graphics g) to do the painting. The actual graph consists of lines (g.drawLine(fromX, fromY, toX, toY)) and some homemade JComponents (myComponent.setBounds(x, y, a, b)) such as small squares and circles. I use these JComponents because I want Tool Tips on them.

On the screen all looks great!

Here's how I print:



But when I try to print it, the outcome on paper doesn't look that great:

All my homemade JComponents are stacked in upper left corner (coords 0, 0) instead of being placed correctly I'm aware that PrinterJob takes the Graphics object, does some transformations and then pipes it to the printer, but why are my components parintet but their coordinates ignored?

What to do .. what to do .. pretty annoying, actually


With kind regards!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know zip about printing, but Tom Jacobs' StandardPrint class works well
for printing components. Might not suit, but worth a look

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=711572

from memory, you have to comment out the references to SpecialPrint class
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic