Example usage for java.awt PrintJob getPageResolution

List of usage examples for java.awt PrintJob getPageResolution

Introduction

In this page you can find the example usage for java.awt PrintJob getPageResolution.

Prototype

public abstract int getPageResolution();

Source Link

Document

Returns the resolution of the page in pixels per inch.

Usage

From source file:PrintTestApp.java

public PrintTestApp() {
    super("PrintTestApp");
    toolkit = getToolkit();// www  . j  a  v a  2 s  .  com
    add("Center", textArea);
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    String name = "Test print job";
    Properties properties = new Properties();
    PrintJob pj = toolkit.getPrintJob(PrintTestApp.this, name, properties);
    if (pj == null)
        textArea.setText("A null PrintJob was returned.");
    else {
        String output = "Name: " + name + "\nProperties: " + properties.toString();
        Dimension pageDim = pj.getPageDimension();
        int resolution = pj.getPageResolution();
        boolean lastPageFirst = pj.lastPageFirst();
        output += "\nPage dimension (in pixels):";
        output += "\n height: " + String.valueOf(pageDim.height);
        output += "\n width: " + String.valueOf(pageDim.width);
        output += "\nResolution (pixels/inch): " + String.valueOf(resolution);
        output += "\nLast Page First: " + String.valueOf(lastPageFirst);
        textArea.setText(output);
        Graphics g = pj.getGraphics();
        g.dispose();
        pj.end();
    }
}