print Text - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

print Text

Demo Code


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
    }
}

Related Tutorials