Have you read the tutorials from the 'source' (aka Oracle)?
Lesson: Printing (The Java™ Tutorials > 2D Graphics)