Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4744405

RFE: lookupPrintServices() to refresh the printers list dynamically

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.0, 1.4.1, 1.4.2, 5.0u6, 5.0u14
    • client-libs
    • 2d
    • b33
    • x86, sparc
    • linux, solaris_8, windows_2000, windows_xp

        *This also happened on Windows platform.

        java version "1.4.1-rc"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
        Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

        When invoke method lookupPrintServices() on class PrinterJob or PrintServiceLookup, the printers list can not refreshed when adding or deleting printers dynamically.

        Steps to follow to reproduce the problem:
         1. Compile and run the included test case
         2. The print dialog shows up and avaible printers information is printed out on screen. Click "cancel" to dismiss the dialog. The test case is pending.
         3. Use Printer Selector Tool to add a new printer into selected printers list and save changes.
         4. Back to the terminal that run the test case an click "enter" button to continue. Then a new thread will be created to invoke the lookupPrintServices() and pop up the print dialog again.
         5. The screen output shows that invoking lookupPrintServices() doesn't reflect the newly added printer information, neither does the print dialog.

        //-------- source code begin-----------//
        import java.awt.print.*;
        import javax.print.*;

        public class MTPrinterTest extends Thread {
            public static void main(String[] args) {
                MTPrinterTest t1 = new MTPrinterTest();
                t1.start();
                
                try {
                    System.in.read();
                } catch (Exception e){}
                
                MTPrinterTest t2 = new MTPrinterTest();
                t2.start();
            }
            public void run() {
                PrinterJob printerJob;
                PrintService[] printServices;

                printerJob = PrinterJob.getPrinterJob();
                printServices = printerJob.lookupPrintServices();
                System.out.println("Number of servies found: " + printServices.length);
                for (int i =0; i< printServices.length; i++)
                    System.out.println("--> Available Printer " + i + ": " + printServices[i]);
                printerJob.printDialog();
            }
        }
        //-------- source code end ----------//

              jgodinez Jennifer Godinez (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: