本文整理汇总了Java中java.awt.print.PrinterJob.defaultPage方法的典型用法代码示例。如果您正苦于以下问题:Java PrinterJob.defaultPage方法的具体用法?Java PrinterJob.defaultPage怎么用?Java PrinterJob.defaultPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.print.PrinterJob
的用法示例。
在下文中一共展示了PrinterJob.defaultPage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPageFormat
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
/**
* Get an instance of {@link java.awt.print.PageFormat}.
* @param pj {@link java.awt.print.PrinterJob} which is
* associated with the default printer.
* @return an instance of <code>PageFormat</code> that describes the size and
* orientation of a page to be printed.
*/
public static PageFormat getPageFormat(PrinterJob pj) {
PageFormat pageFormat = null;
pageFormat = pj.defaultPage();
Paper p = pageFormat.getPaper();
int pageOrientation = getPreferences().getInt(PROP_PAGE_ORIENTATION, pageFormat.getOrientation());
double paperWidth = getPreferences().getDouble(PROP_PAGE_WIDTH, p.getWidth());
double paperHeight = getPreferences().getDouble(PROP_PAGE_HEIGHT, p.getHeight());
double iaWidth = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, p.getImageableWidth());
double iaHeight = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, p.getImageableHeight());
double iaX = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_X, p.getImageableX());
double iaY = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_Y, p.getImageableY());
pageFormat.setOrientation(pageOrientation);
p.setSize(paperWidth, paperHeight);
p.setImageableArea(iaX, iaY, iaWidth, iaHeight);
pageFormat.setPaper(p);
return pageFormat;
}
示例2: getPageFormat
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public PageFormat getPageFormat() {
PrinterJob job = PrinterJob.getPrinterJob();
if (myPageFormat == null) {
myPageFormat = job.defaultPage();
// restore
myPageFormat.setOrientation(round(get(PAGE_ORIENTATION, PageFormat.PORTRAIT)));
Paper paper = myPageFormat.getPaper();
if (get(PAPER_WIDTH, null) != null && get(PAPER_HEIGHT, null) != null) {
paper.setSize(get(PAPER_WIDTH, INCH), get(PAPER_HEIGHT, INCH));
}
if (get(AREA_X, null) != null && get(AREA_Y, null) != null && get(AREA_WIDTH, null) != null && get(AREA_HEIGHT, null) != null) {
paper.setImageableArea(get(AREA_X, INCH), get(AREA_Y, INCH), get(AREA_WIDTH, INCH), get(AREA_HEIGHT, INCH));
}
myPageFormat.setPaper(paper);
}
return myPageFormat;
}
示例3: printTest
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
private static void printTest() {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.defaultPage();
Paper paper = new Paper();
double margin = 36; // half inch
paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2,
paper.getHeight() - margin * 2);
pf.setPaper(paper);
pj.setPrintable(new PrintTestLexmarkIQ(), pf);
if (pj.printDialog()) {
try {
pj.print();
} catch (PrinterException e) {
System.out.println(e);
}
}
}
示例4: createChartPrintJob
import java.awt.print.PrinterJob; //导入方法依赖的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);
}
}
}
}
示例5: createChartPrintJob
import java.awt.print.PrinterJob; //导入方法依赖的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);
}
}
}
}
示例6: createChartPrintJob
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
/**
* Creates a print job for the chart.
*/
public void createChartPrintJob() {
//FIXME try to replace swing print stuff by swt
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) {
MessageBox messageBox = new MessageBox(
canvas.getShell(), SWT.OK | SWT.ICON_ERROR );
messageBox.setMessage( e.getMessage() );
messageBox.open();
}
}
}
}
示例7: pageDialogExample
import java.awt.print.PrinterJob; //导入方法依赖的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();
}
示例8: PolylinePrintingTest
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public PolylinePrintingTest() throws PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat pf = job.defaultPage();
Paper p = pf.getPaper();
p.setImageableArea(0,0,p.getWidth(), p.getHeight());
pf.setPaper(p);
job.setPrintable(this, pf);
if (job.printDialog()) {
job.print();
}
}