use of java.awt.print.PrinterJob in project jdk8u_jdk by JetBrains.
the class SetPrintServiceTest method main.
public static void main(String[] args) {
PrintServiceStub service = new PrintServiceStub("CustomPrintService");
PrinterJob printerJob = PrinterJob.getPrinterJob();
try {
printerJob.setPrintService(service);
System.out.println("Test Passed");
} catch (PrinterException e) {
throw new RuntimeException("Test FAILED", e);
}
}
use of java.awt.print.PrinterJob in project jdk8u_jdk by JetBrains.
the class PageDlgApp method main.
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");
}
}
use of java.awt.print.PrinterJob in project jdk8u_jdk by JetBrains.
the class ImageableAreaTest method printWithCustomImageareaSize.
private static void printWithCustomImageareaSize() {
final JTable table = createAuthorTable(18);
PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
printAttributes.add(DialogTypeSelection.NATIVE);
printAttributes.add(new Copies(1));
printAttributes.add(new MediaPrintableArea(0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
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(printAttributes);
if (printAccepted) {
try {
job.print(printAttributes);
closeFrame();
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
throw new RuntimeException("User cancels the printer job!");
}
}
use of java.awt.print.PrinterJob in project jdk8u_jdk by JetBrains.
the class RadialGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("RadialGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.print.PrinterJob in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method printTexture.
private static void printTexture() {
f = new JFrame("Texture Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
Aggregations