Package java.awt.print

Examples of java.awt.print.PrinterJob


    public static Font getExtendedFont(int pointSize, int typeFace, boolean isBold, boolean isItalic){
        return getPortableFont(pointSize, typeFace, isBold, isItalic);
    }
    public static PageFormat getDefaultPrintOptions(){
        PrinterJob pjob = PrinterJob.getPrinterJob();
        PageFormat pf = pjob.defaultPage();
        return pf;
    }
View Full Code Here


    public PrintSetupActionListener() {
        super();
    }

    public void actionPerformed(ActionEvent e) {
        PrinterJob pjob = PrinterJob.getPrinterJob();

        // Get and change default page format settings if necessary.
        PageFormat pf = pjob.defaultPage();
       
        // Set the default options.  CraigM: 31/03/2008.
        pf.setOrientation(PrintUtilities.getDefaultPrintOptions().getOrientation());
        pf.setPaper(PrintUtilities.getDefaultPrintOptions().getPaper());

        // Show page format dialog with page format settings.
        pf = pjob.pageDialog(pf);
       
        // Update the default options.  CraigM: 31/03/2008.
        PrintUtilities.getDefaultPrintOptions().setOrientation(pf.getOrientation());
        PrintUtilities.getDefaultPrintOptions().setPaper(pf.getPaper());
    }
View Full Code Here

    private void jmniPrintVMActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jmniPrintVMActionPerformed
    {//GEN-HEADEREND:event_jmniPrintVMActionPerformed

        if (getAktuelleBasis() != null)
        {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(getVMObject());
            if (printJob.printDialog())
            {
                try
                {
                    printJob.print();
                } catch (PrinterException pe)
                {
                    System.out.println("Error printing: " + pe);
                }
            }
View Full Code Here

     *  it.
     */
    protected void _print() {
        // Build a set of attributes
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PrinterJob job = PrinterJob.getPrinterJob();

        if (this instanceof Pageable) {
            job.setPageable((Pageable) this);
        } else if (this instanceof Printable) {
            //PageFormat format = job.pageDialog(job.defaultPage());
            //job.setPrintable((Printable) this, format);
            job.setPrintable((Printable)this);
        } else {
            // Can't print it.
            return;
        }

        if (job.printDialog(aset)) {
            try {
                job.print(aset);
            } catch (Exception ex) {
                MessageHandler.error("Printing Failed", ex);
            }
        }
    }
View Full Code Here

     *  the user's choice of portrait vs. landscape
     */
    protected void _printCrossPlatform() {
        // Build a set of attributes
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintable(plot);

        if (job.printDialog(aset)) {
            try {
                job.print(aset);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, "Printing failed:\n"
                        + ex.toString(), "Print Error",
                        JOptionPane.WARNING_MESSAGE);
            }
View Full Code Here

    /** Print using the native dialog.
     *  FIXME: This method does not seem to honor the user's
     *  choice of portrait vs. landscape.
     */
    protected void _printNative() {
        PrinterJob job = PrinterJob.getPrinterJob();

        //PageFormat pageFormat = job.defaultPage();
        //job.setPrintable(plot, pageFormat);
        job.setPrintable(plot);

        if (job.printDialog()) {
            try {
                // job.print() eventually
                // calls PlotBox.print(Graphics, PageFormat)
                job.print();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, "Printing failed:\n"
                        + ex.toString(), "Print Error",
                        JOptionPane.WARNING_MESSAGE);
            }
View Full Code Here

            if (event.getSource() == _fillButton) {
                fillPlot();
            } else if (event.getSource() == _printButton) {
                // FIXME:  Code duplication with PlotFrame._printCrossPlatform
                PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                PrinterJob job = PrinterJob.getPrinterJob();

                // rbeyer@LPL.Arizona.EDU: Get the Page Format and use it.
                //PageFormat format = job.pageDialog(job.defaultPage());
                //job.setPrintable(PlotBox.this, format);
                job.setPrintable(PlotBox.this);

                if (job.printDialog(aset)) {
                    try {
                        job.print(aset);
                    } catch (Exception ex) {
                        Component ancestor = getTopLevelAncestor();
                        JOptionPane.showMessageDialog(ancestor,
                                "Printing failed:\n" + ex.toString(),
                                "Print Error", JOptionPane.WARNING_MESSAGE);
View Full Code Here

        return new AbstractAction(PRINT) {
            public void actionPerformed(ActionEvent e) {
                View view = app.getCurrentView();

                if ((view != null) && view instanceof Printable) {
                    PrinterJob job = PrinterJob.getPrinterJob();
                    PageFormat format = job.pageDialog(job.defaultPage());
                    job.setPrintable((Printable) view, format);

                    if (job.printDialog()) {
                        try {
                            job.print();
                        } catch (Exception ex) {
                            app.showError("PrintingFailed", ex);
                        }
                    }
                } else if ((view != null) && view instanceof Pageable) {
                    PrinterJob job = PrinterJob.getPrinterJob();
                    job.pageDialog(job.defaultPage());
                    job.setPageable((Pageable) view);

                    if (job.printDialog()) {
                        try {
                            job.print();
                        } catch (Exception ex) {
                            app.showError("PrintingFailed", ex);
                        }
                    }
                }
View Full Code Here

  public void printCard() {
    JPanel panel = etiketPngHazirla();
    if (panel == null) {
      return;
    }
    PrinterJob printJob = PrinterJob.getPrinterJob();
    PrintService printService = getPrintService(property.getService());

    PageFormat format = new PageFormat();
    format.setOrientation(PageFormat.PORTRAIT);
    Paper paper = format.getPaper();
    paper.setImageableArea(0, 0, panel.getWidth(), panel.getHeight());
    format.setPaper(paper);

    printJob.setPrintable(new Printer(panel), format);

    int printCount = (int) JSpinnerAdet.getValue() / property.getSutun();
    for (int i = 0; i < printCount; i++) {

      try {
        printJob.setPrintService(printService);
        printJob.print();
      } catch (PrinterException e) {
        e.printStackTrace();
      }
    }
  }
View Full Code Here

        try{
       
            // initialize if required           
            if( KPrintJobClass.defaultPrinterJob == null || KPrintJobClass.defaultPageFormat == null ){

                PrinterJob printerJob = PrinterJob.getPrinterJob();
                KPrintJobClass.setPrintingDefaults(
                    printerJob, printerJob.defaultPage()
                );
            };
                       
            KPrintJobClass.defaultPrinterJob.printDialog();
View Full Code Here

TOP

Related Classes of java.awt.print.PrinterJob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.