This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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