本文整理汇总了Java中java.awt.print.PrinterJob.pageDialog方法的典型用法代码示例。如果您正苦于以下问题:Java PrinterJob.pageDialog方法的具体用法?Java PrinterJob.pageDialog怎么用?Java PrinterJob.pageDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.print.PrinterJob
的用法示例。
在下文中一共展示了PrinterJob.pageDialog方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
/**
*
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() instanceof mxGraphComponent)
{
mxGraphComponent graphComponent = (mxGraphComponent) e
.getSource();
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat format = pj.pageDialog(graphComponent
.getPageFormat());
if (format != null)
{
graphComponent.setPageFormat(format);
graphComponent.zoomAndCenter();
}
}
}
示例2: showPageSetup
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public boolean showPageSetup() {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat oldFormat = getPageFormat();
PageFormat newFormat = job.pageDialog(oldFormat);
if (oldFormat == newFormat) {
return false;
}
myPageFormat = newFormat;
// save
set(PAGE_ORIENTATION, myPageFormat.getOrientation());
Paper paper = myPageFormat.getPaper();
set(PAPER_WIDTH, paper.getWidth());
set(PAPER_HEIGHT, paper.getHeight());
set(AREA_X, paper.getImageableX());
set(AREA_Y, paper.getImageableY());
set(AREA_WIDTH, paper.getImageableWidth());
set(AREA_HEIGHT, paper.getImageableHeight());
return true;
}
示例3: getCustomEditor
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
/**
* @return <tt>null</tt> Shows pageDialog, however.
*/
public java.awt.Component getCustomEditor() {
PageFormat pf = (PageFormat) getValue();
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat npf = pj.pageDialog(pf);
//setValue(npf);
((PrintSettings)PrintSettings.findObject(PrintSettings.class)).setPageFormat((PageFormat) npf.clone());
pj.cancel();
return null;
}
示例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: actionPerformed
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent event) {
if (event.getSource() == _fillButton) {
fillPlot();
}
else if (event.getSource() == _printButton) {
PrinterJob job = PrinterJob.getPrinterJob();
// [email protected]: Get the Page Format and use it.
PageFormat format = job.pageDialog( job.defaultPage() );
job.setPrintable(PlotBox.this, format);
if (job.printDialog()) {
try {
job.print();
} catch (Exception ex) {
Component ancestor = getTopLevelAncestor();
JOptionPane.showMessageDialog(ancestor,
"Printing failed:\n" + ex.toString(),
"Print Error", JOptionPane.WARNING_MESSAGE);
}
}
}
else if (event.getSource() == _resetButton) {
resetAxes();
}
else if (event.getSource() == _formatButton) {
PlotFormatter fmt = new PlotFormatter(PlotBox.this);
fmt.openModal();
}
}
示例6: 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);
}
}
}
}
示例7: 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();
}
}
}
}
示例8: main
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String[] instructions =
{
"Visual inspection of the dialog is needed. ",
"It should be a Printer Job Setup Dialog",
"Do nothing except Cancel",
"You must NOT press OK",
};
SwingUtilities.invokeAndWait(() -> {
JOptionPane.showMessageDialog(
(Component) null,
instructions,
"information", JOptionPane.INFORMATION_MESSAGE);
});
PrinterJob pj = PrinterJob.getPrinterJob();
PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
pSet.add(DialogTypeSelection.NATIVE);
if ((pj.pageDialog(pSet)) != null) {
throw
new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)"
+ " does not return null when dialog is cancelled");
}
}
示例9: 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();
}
示例10: actionPerformed
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
/**
*
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof mxGraphComponent) {
mxGraphComponent graphComponent = (mxGraphComponent) e.getSource();
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat format = pj.pageDialog(graphComponent.getPageFormat());
if (format != null) {
graphComponent.setPageFormat(format);
graphComponent.zoomAndCenter();
}
}
}
示例11: main
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
String[] instructions
= {
"Page Dialog will be shown.",
"Change top(in) margin value from 1.0 to 2.0",
"Then select OK."
};
SwingUtilities.invokeAndWait(() -> {
JOptionPane.showMessageDialog((Component) null,
instructions, "Instructions",
JOptionPane.INFORMATION_MESSAGE);
});
PrinterJob pj = PrinterJob.getPrinterJob();
try {
HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PageFormat pf;
pf = pj.pageDialog(aset);
double left = pf.getImageableX();
double top = pf.getImageableY();
System.out.println("pageDialog - left/top from pageFormat: " + left / 72
+ " " + top / 72);
System.out.println("pageDialog - left/top from attribute set: "
+ getPrintableXFromASet(aset) + " "
+ getPrintableYFromASet(aset));
if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
throw new RuntimeException("Top margin value not updated");
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: main
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public static void main(String args[]) {
PrinterJob job = PrinterJob.getPrinterJob();
if (job == null) {
return;
}
PrintRequestAttributeSet pSet =
new HashPrintRequestAttributeSet();
pSet.add(DialogTypeSelection.NATIVE);
job.printDialog(pSet);
try {
job.pageDialog(pSet);
} catch (StackOverflowError e) {
throw new RuntimeException("StackOverflowError is thrown");
}
}
示例13: pageMarginTest
import java.awt.print.PrinterJob; //导入方法依赖的package包/类
public static void pageMarginTest() {
PrinterJob pj = PrinterJob.getPrinterJob();
HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PageFormat pf;
pf = pj.pageDialog(aset);
}