Results 1 to 2 of 2
  1. #1
    leonard is offline Member
    Join Date
    Jul 2007
    Posts
    43
    Rep Power
    0

    Default Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException

    I have this code for printing a html file.

    I pass a String with the html code in textString.
    Java Code:
    class Print
    {
    public void Print(String textString)
    {
    DocFlavor dflavor = DocFlavor.STRING.TEXT_HTML;
    PrintService[] services = PrintServiceLookup.lookupPrintServices(
    dflavor , null);
    PrintService defaultService = PrintServiceLookup
    .lookupDefaultPrintService();
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    PrintService service = ServiceUI.printDialog(null, 50, 50, services,
    defaultService, dflavor , pras);
    if (service != null)
    {
    DocPrintJob job = service.createPrintJob();
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(textString, dflavor , das);
    try
    {
    job.print(doc, pras);
    }
    catch (PrintException pe)
    {
    }
    }
    }
    }
    this is the complete error
    Java Code:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: services must be non-null and non-empty
    at javax.print.ServiceUI.printDialog(Unknown Source)
    at PrintHtml.printHtml(PrintHtml.java:24)

  2. #2
    tommy is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    I suspect your variable 'services' and/or 'defaultService' is null or blank values. That may mean your printer does not support your intended 'flavor'.

Similar Threads

  1. Replies: 2
    Last Post: 12-14-2009, 02:46 AM
  2. Replies: 3
    Last Post: 01-29-2008, 02:37 AM
  3. Replies: 1
    Last Post: 08-06-2007, 07:07 AM
  4. Replies: 1
    Last Post: 07-25-2007, 11:55 PM
  5. Replies: 1
    Last Post: 07-16-2007, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •