KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > print > PrintServiceLookup

javax.print
Class PrintServiceLookup

java.lang.Object
  extended by javax.print.PrintServiceLookup
See Also:
Top Examples, Source Code

public abstract PrintService getDefaultPrintService()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
                                                                AttributeSet attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1983]java print
By sandeepjom { at } gmail { dot } com on 2008/10/13 12:35:11  Rate
all deatil how print is used injava how to print database

public abstract PrintService[] getPrintServices()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[144]Error in getting print service
By Anonymous on 2003/09/25 06:21:06  Rate
import javax.print.*; 
 import javax.print.attribute.*; 
 import java.io.*; 
  
  
 public class Printing  {  
   public static void main ( String args [  ]  )  throws Exception  {  
     String filename = args [ 0 ] ; 
     PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet (  ) ; 
     DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG; 
     //PrintService printService [  ]  = PrintServiceLookup.lookupPrintServices ( flavor, pras ) ; 
   PrintService printService [  ]  = PrintServiceLookup.getPrintServices (  ) ; 
     PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService (  ) ; 
     PrintService service = ServiceUI.printDialog ( null, 200, 200, printService, defaultService, flavor, pras ) ; 
     if  ( service != null )   {  
       DocPrintJob job = service.createPrintJob (  ) ; 
       FileInputStream fis = new FileInputStream ( filename ) ; 
       DocAttributeSet das = new HashDocAttributeSet (  ) ; 
       Doc doc = new SimpleDoc ( fis, flavor, das ) ; 
       job.print ( doc, pras ) ; 
       Thread.sleep ( 10000 ) ; 
      }  
     System.exit ( 0 ) ; 
    }  
  }  
  
  
  
 gives following error :: 
  
  
 Printing.java:11: non-static method getPrintServices (  )  cannot be referenced from a static context 
 PrintService printService [  ]  = PrintServiceLookup.getPrintServices (  ) ; 
  
  
 


public abstract PrintService[] getPrintServices(DocFlavor flavor,
                                                AttributeSet attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final PrintService lookupDefaultPrintService()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors,
                                                                       AttributeSet attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final PrintService[] lookupPrintServices(DocFlavor flavor,
                                                       AttributeSet attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[145]Could not find hp deskjet printer
By Anonymous on 2003/01/10 01:47:56  Rate
import javax.print.*; 
 import javax.print.attribute.*; 
 import java.io.*; 
  
  
 public class Printing  {  
   public static void main ( String args [  ]  )   {  
   try {  
     String filename = args [ 0 ] ; 
     PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet (  ) ; 
     DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG; 
     PrintService printService [  ]  = PrintServiceLookup.lookupPrintServices ( flavor, pras ) ; 
   //PrintService printService [  ]  = PrintServiceLookup.getPrintServices (  ) ; 
     //PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService (  ) ; 
     //PrintService service = ServiceUI.printDialog ( null, 200, 200, printService, defaultService, flavor, pras ) ; 
     //if  ( printService.length != 0 )   {  
       DocPrintJob job = printService [ 0 ] .createPrintJob (  ) ; 
       FileInputStream fis = new FileInputStream ( filename ) ; 
       DocAttributeSet das = new HashDocAttributeSet (  ) ; 
       Doc doc = new SimpleDoc ( fis, flavor, das ) ; 
       job.print ( doc, pras ) ; 
       Thread.sleep ( 10000 ) ; 
     // }  
     System.exit ( 0 ) ; 
    }  
   catch ( Exception e )  {  
     System.out.println ( "Exception is " + e ) ; 
    }  
    }  
  }  
  
  
 hp deskjet printer is attached eventhough it throws following exception :: 
 Exception is java.lang.ArrayIndexOutOfBoundsException 
 it is because here no services found so printService [ 0 ]  gives the above error


public PrintServiceLookup()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static boolean registerService(PrintService service)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static boolean registerServiceProvider(PrintServiceLookup sp)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags