Prints a JavaFX node. - Java JavaFX

Java examples for JavaFX:Node

Description

Prints a JavaFX node.

Demo Code


//package com.java2s;
import javafx.print.Printer;
import javafx.print.PrinterJob;
import javafx.scene.Node;

public class Main {
    /**/*from  w ww . j av  a  2 s  .c  o m*/
     * Prints a node.
     *
     * @param node The scene node to be printed.
     */
    public static void print(final Node node) {
        Printer printer = Printer.getDefaultPrinter();

        PrinterJob job = PrinterJob.createPrinterJob(printer);
        if (job != null && job.showPrintDialog(null)) {
            boolean success = job.printPage(node);
            if (success) {
                job.endJob();
            }
        }
    }
}

Related Tutorials