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

RFE: lookupPrintServices() to refresh the printers list dynamically

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 1.4.1, 1.4.2, 5.0u6, 5.0u14
    • Fix Version/s: 6
    • Component/s: client-libs
    • Subcomponent:
      2d
    • Resolved In Build:
      b33
    • CPU:
      x86, sparc
    • OS:
      linux, solaris_8, windows_2000, windows_xp

      Backports

        Description

        *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 ----------//

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: