当前位置: 首页>>代码示例>>Java>>正文


Java PrinterException类代码示例

本文整理汇总了Java中java.awt.print.PrinterException的典型用法代码示例。如果您正苦于以下问题:Java PrinterException类的具体用法?Java PrinterException怎么用?Java PrinterException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PrinterException类属于java.awt.print包,在下文中一共展示了PrinterException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import java.awt.print.PrinterException; //导入依赖的package包/类
public int print(final Graphics graphics,
                 final PageFormat pageFormat, final int pageIndex)
        throws PrinterException {

    final int retVal =
        printDelegatee.print(graphics, pageFormat, pageIndex);
    if (retVal != NO_SUCH_PAGE && !isAborted()) {
        if (SwingUtilities.isEventDispatchThread()) {
            updateStatusOnEDT(pageIndex);
        } else {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    updateStatusOnEDT(pageIndex);
                }
            });
        }
    }
    return retVal;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:PrintingStatus.java

示例2: print

import java.awt.print.PrinterException; //导入依赖的package包/类
void print(List<Paper> papers) {
        PrinterJob job = PrinterJob.getPrinterJob();
        myPapers = papers;
//out("SET PAPER: " + myPapers);

        if (job == null) {
            return;
        }
        job.setPrintable(this, Config.getDefault().getPageFormat());

        try {
            if (job.printDialog()) {
                job.print();
            }
        }
        catch (PrinterException e) {
            printError(i18n(Printer.class, "ERR_Printer_Problem", e.getLocalizedMessage())); // NOI18N
        }
        myPapers = null;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Printer.java

示例3: createChartPrintJob

import java.awt.print.PrinterException; //导入依赖的package包/类
/**
 * Creates a print job for the chart.
 */

@Override
public void createChartPrintJob() {

	PrinterJob job = PrinterJob.getPrinterJob();
	PageFormat pf = job.defaultPage();
	PageFormat pf2 = job.pageDialog(pf);
	if (pf2 != pf) {
		job.setPrintable(this, pf2);
		if (job.printDialog()) {
			try {
				job.print();
			} catch (PrinterException e) {
				JOptionPane.showMessageDialog(this, e);
			}
		}
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:AbstractChartPanel.java

示例4: setAttributes

import java.awt.print.PrinterException; //导入依赖的package包/类
@Override
protected void setAttributes(PrintRequestAttributeSet attributes)
                             throws PrinterException {
    super.setAttributes(attributes);
    if (attributes == null) {
        return; // now always use attributes, so this shouldn't happen.
    }
    Attribute attr = attributes.get(Media.class);
    if (attr instanceof CustomMediaTray) {
        CustomMediaTray customTray = (CustomMediaTray)attr;
        String choice = customTray.getChoiceName();
        if (choice != null) {
            mOptions = " InputSlot="+ choice;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PSPrinterJob.java

示例5: pageDialogExample

import java.awt.print.PrinterException; //导入依赖的package包/类
public void pageDialogExample() throws PrinterException
{
    PrinterJob job = PrinterJob.getPrinterJob();
    PageFormat originalPageFormat = job.defaultPage();
    PageFormat pageFormat = job.pageDialog(originalPageFormat);

    if(originalPageFormat == pageFormat) return;

    job.setPrintable(this,pageFormat);
    job.print();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:PageDlgPrnButton.java

示例6: print

import java.awt.print.PrinterException; //导入依赖的package包/类
@Override public int print(Graphics default_graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
	List<Image> images = getPrintPages(pageFormat);
	if(pageIndex>=images.size())
		return NO_SUCH_PAGE;
	Graphics2D graphics = (Graphics2D)default_graphics.create();
	graphics.translate(pageFormat.getImageableX(),
			pageFormat.getImageableY());
	graphics.drawImage(images.get(pageIndex), 0, 0, null);
	Thread.yield(); //yield shortly, so that the image is painted
	return PAGE_EXISTS;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:12,代码来源:Simulation.java

示例7: print

import java.awt.print.PrinterException; //导入依赖的package包/类
@Override public int print(Graphics default_graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
	if(pageIndex!=0)
		return NO_SUCH_PAGE;
	pageFormat.setOrientation(PageFormat.LANDSCAPE);

	Color foreground = this.foreground, background = this.background, grid = this.grid;
	this.foreground = Color.BLACK; this.background = Color.WHITE; this.grid = Color.LIGHT_GRAY;

	Graphics2D graphics = (Graphics2D) default_graphics;
	graphics.translate(pageFormat.getImageableX(),
			pageFormat.getImageableY());
	this.paint(graphics);
	Thread.yield(); //yield shortly that the graphics are printed properly

	this.foreground = foreground; this.background = background; this.grid = grid;
	return PAGE_EXISTS;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:18,代码来源:SimulationOscilloscope.java

示例8: setPrinterNameAttrib

import java.awt.print.PrinterException; //导入依赖的package包/类
private void setPrinterNameAttrib(String printerName) {
    PrintService service = this.getPrintService();

    if (printerName == null) {
        return;
    }

    if (service != null && printerName.equals(service.getName())) {
        return;
    } else {
        PrintService []services = PrinterJob.lookupPrintServices();
        for (int i=0; i<services.length; i++) {
            if (printerName.equals(services[i].getName())) {

                try {
                    this.setPrintService(services[i]);
                } catch (PrinterException e) {
                }
                return;
            }
        }
    }
//** END Functions called by native code for querying/updating attributes

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:WPrinterJob.java

示例9: redrawRegion

import java.awt.print.PrinterException; //导入依赖的package包/类
/**
  * Redraw a rectanglular area using a proxy graphics
  */
public abstract void redrawRegion(Rectangle2D region,
                                  double scaleX, double scaleY,
                                  Shape clip,
                                  AffineTransform devTransform)

                throws PrinterException ;
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:PathGraphics.java

示例10: print

import java.awt.print.PrinterException; //导入依赖的package包/类
/**
 * Prints the page at the specified index into the specified
 * {@link Graphics} context in the specified
 * format.  A <code>PrinterJob</code> calls the
 * <code>Printable</code> interface to request that a page be
 * rendered into the context specified by
 * <code>graphics</code>.  The format of the page to be drawn is
 * specified by <code>pageFormat</code>.  The zero based index
 * of the requested page is specified by <code>pageIndex</code>.
 * If the requested page does not exist then this method returns
 * NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned.
 * The <code>Graphics</code> class or subclass implements the
 * {@link PrinterGraphics} interface to provide additional
 * information.  If the <code>Printable</code> object
 * aborts the print job then it throws a {@link PrinterException}.
 * @param graphics the context into which the page is drawn
 * @param pageFormat the size and orientation of the page being drawn
 * @param pageIndex the zero based index of the page to be drawn
 * @return PAGE_EXISTS if the page is rendered successfully
 *         or NO_SUCH_PAGE if <code>pageIndex</code> specifies a
 *         non-existent page.
 * @exception java.awt.print.PrinterException
 *         thrown when the print job is terminated.
 */
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
             throws PrinterException {

    int result;

    /* This method will be called by the PrinterJob on a thread other
     * that the application's thread. We hold on to the graphics
     * until we can rendevous with the application's thread and
     * hand over the graphics. The application then does all the
     * drawing. When the application is done drawing we rendevous
     * again with the PrinterJob thread and release the Graphics
     * so that it knows we are done.
     */

    /* Add the graphics to the message queue of graphics to
     * be rendered. This is really a one slot queue. The
     * application's thread will come along and remove the
     * graphics from the queue when the app asks for a graphics.
     */
    graphicsToBeDrawn.append( (Graphics2D) graphics);

    /* We now wait for the app's thread to finish drawing on
     * the Graphics. This thread will sleep until the application
     * release the graphics by placing it in the graphics drawn
     * message queue. If the application signals that it is
     * finished drawing the entire document then we'll get null
     * returned when we try and pop a finished graphic.
     */
    if (graphicsDrawn.pop() != null) {
        result = PAGE_EXISTS;
    } else {
        result = NO_SUCH_PAGE;
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:PrintJob2D.java

示例11: print

import java.awt.print.PrinterException; //导入依赖的package包/类
@Override
public int print(Graphics g, PageFormat pf, int i) throws PrinterException 
{
	if (i > 0) return NO_SUCH_PAGE;
	Graphics2D g2 = (Graphics2D)g;
	
	// translate to printable area
	g2.translate(pf.getImageableX(), pf.getImageableY());
	
	// now attempt to scale if needed
	double scale = Math.min(pf.getImageableWidth() / getWidth(), pf.getImageableHeight() / getHeight());
	int width = getWidth();
	if ((scale > 1.05) || (scale < 0.95)) {
		g2.scale(scale, scale);
		width *= scale;
	}
	
	// final translate to center of printable area after we know scaled size
	if (width < pf.getImageableWidth()) {
		int centerx = (int) ((pf.getImageableWidth() - width)/2.0);
		g2.translate(centerx, 0);
	}

	paint(g);
	return PAGE_EXISTS;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:27,代码来源:Code39.java

示例12: printWithJavaPrintDialog

import java.awt.print.PrinterException; //导入依赖的package包/类
private static void printWithJavaPrintDialog() {
    final JTable table = createAuthorTable(50);
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}"));

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog();
    if (printAccepted) {
        try {
            job.print();
            closeFrame();
        } catch (PrinterException e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ImageableAreaTest.java

示例13: print

import java.awt.print.PrinterException; //导入依赖的package包/类
public int print(Graphics g, PageFormat pf, int pageIndex)
                     throws PrinterException {

    if (pageIndex > 0) {
        return Printable.NO_SUCH_PAGE;
    }
    g.translate((int) pf.getImageableX(), (int) pf.getImageableY());
    g.setFont(new Font("Dialog", Font.PLAIN, 36));
    g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100);
    return Printable.PAGE_EXISTS;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:PrintLatinCJKTest.java

示例14: createChartPrintJob

import java.awt.print.PrinterException; //导入依赖的package包/类
/**
 * Creates a print job for the chart.
 */
public void createChartPrintJob() {

    PrinterJob job = PrinterJob.getPrinterJob();
    PageFormat pf = job.defaultPage();
    PageFormat pf2 = job.pageDialog(pf);
    if (pf2 != pf) {
        job.setPrintable(this, pf2);
        if (job.printDialog()) {
            try {
                job.print();
            }
            catch (PrinterException e) {
                JOptionPane.showMessageDialog(this, e);
            }
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:ChartPanel.java

示例15: print

import java.awt.print.PrinterException; //导入依赖的package包/类
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) 
    throws PrinterException {
    if (pageIndex != 0) {
        return NO_SUCH_PAGE;
    }
    /*
    CairoImage image = new CairoImage( 
            this.getBounds().width, this.getBounds().height );
    Graphics2D g2 = image.createGraphics2D();
    double x = pageFormat.getImageableX();
    double y = pageFormat.getImageableY();
    double w = pageFormat.getImageableWidth();
    double h = pageFormat.getImageableHeight();
    this.chart.draw(
        g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null
    );
    */
    return PAGE_EXISTS;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:ChartComposite.java


注:本文中的java.awt.print.PrinterException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。