Printers.java

00001 package edu.stanford.hci.r3.printing;
00002 
00003 import java.awt.Desktop;
00004 import java.io.File;
00005 import java.io.IOException;
00006 
00007 import javax.print.PrintServiceLookup;
00008 
00017 public class Printers {
00018 
00022         public static Printer getDefaultPrinter() {
00023                 return new Printer(PrintServiceLookup.lookupDefaultPrintService());
00024         }
00025 
00030         public static void print(File f) {
00031                 if (!Desktop.isDesktopSupported()
00032                                 || !Desktop.getDesktop().isSupported(Desktop.Action.PRINT)) {
00033                         System.err.println("Printers: Cannot print the file, because "
00034                                         + "Java 1.6 Desktop printing is not supported.");
00035                         return;
00036                 }
00037 
00038                 // use the system's default printing mechanism
00039                 try {
00040                         Desktop.getDesktop().print(f);
00041                 } catch (IOException e) {
00042                         e.printStackTrace();
00043                 }
00044         }
00045 }

Generated on Sat Apr 14 18:21:37 2007 for R3 Paper Toolkit by  doxygen 1.4.7