當前位置: 首頁>>代碼示例>>Java>>正文


Java PageFormat.clone方法代碼示例

本文整理匯總了Java中java.awt.print.PageFormat.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java PageFormat.clone方法的具體用法?Java PageFormat.clone怎麽用?Java PageFormat.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.print.PageFormat的用法示例。


在下文中一共展示了PageFormat.clone方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validatePage

import java.awt.print.PageFormat; //導入方法依賴的package包/類
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:RasterPrinterJob.java

示例2: validatePage

import java.awt.print.PageFormat; //導入方法依賴的package包/類
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
private PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:Win32PrintJob.java

示例3: pageDialog

import java.awt.print.PageFormat; //導入方法依賴的package包/類
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(Win32PrintServiceLookup.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:71,代碼來源:WPrinterJob.java

示例4: pageDialog

import java.awt.print.PageFormat; //導入方法依賴的package包/類
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The {@code page} argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original {@code page} object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original {@code page} object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original {@code page} object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(PrintServiceLookupProvider.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:71,代碼來源:WPrinterJob.java

示例5: defaultPage

import java.awt.print.PageFormat; //導入方法依賴的package包/類
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Note: PageFormat.getPaper() returns a clone and getDefaultPage()
 * gets that clone so it won't overwrite the original paper.
 */
@Override
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    getDefaultPage(newPage);
    return newPage;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:WPrinterJob.java


注:本文中的java.awt.print.PageFormat.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。