private synchronized void refreshServices() { printers = peer.getAllPrinterNames(); if (printers == null) { // In Windows it is safe to assume no default if printers == null so we // don't get the default. printServices = new PrintService[0]; return; } PrintService[] newServices = new PrintService[printers.length]; PrintService defService = getDefaultPrintService(); for (int p = 0; p < printers.length; p++) { if (defService != null && printers[p].equals(defService.getName())) { newServices[p] = defService; } else { if (printServices == null) { newServices[p] = new Win32PrintService(printers[p], peer); } else { int j; for (j = 0; j < printServices.length; j++) { if ((printServices[j] != null) && (printers[p].equals(printServices[j].getName()))) { newServices[p] = printServices[j]; printServices[j] = null; break; } } if (j == printServices.length) { newServices[p] = new Win32PrintService(printers[p], peer); } } } } printServices = newServices; }