Here you can find the source of getPrinterJComboBox()
public static JComboBox<String> getPrinterJComboBox()
//package com.java2s; //License from project: Open Source License import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.swing.JComboBox; public class Main { public static JComboBox<String> getPrinterJComboBox() { JComboBox<String> box = new JComboBox<>(); PrintService[] services = PrintServiceLookup.lookupPrintServices( null, null);/*from w w w .j a v a 2 s.co m*/ for (PrintService printService : services) { box.addItem(printService.getName()); } // Set to default printer box.setSelectedItem(getDefaultPrinterName()); return box; } public static String getDefaultPrinterName() { if (PrintServiceLookup.lookupDefaultPrintService() != null) { return PrintServiceLookup.lookupDefaultPrintService().getName(); } return ""; // no default printer specified } }