Java examples for 2D Graphics:Print
print Text
import java.awt.*; import javax.swing.*; import java.awt.print.*; import java.util.ArrayList; import java.util.StringTokenizer; public class Main{ public static void printText(String text) throws PrinterException { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(new TextPrinter(text)); if (job.printDialog()) job.print();//from w w w . j ava 2s . c o m } }