Displaying the Page Format Dialog - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

Displaying the Page Format Dialog

Demo Code

import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;

public class Main {

  public void m() throws Exception {
    PrinterJob pjob = PrinterJob.getPrinterJob();

    // Get and change default page format settings if necessary.
    PageFormat pf = pjob.defaultPage();
    pf.setOrientation(PageFormat.LANDSCAPE);

    // Show page format dialog with page format settings.
    pf = pjob.pageDialog(pf);//ww  w. ja v a2s.co m
  }
}

Related Tutorials