List of usage examples for javax.print.attribute PrintServiceAttributeSet get
public Attribute get(Class<?> category);
From source file:com.akman.enjoyfood.SelectPrinters.java
/** * This method get all the printer installed in the system. Add then into * JTable./*from w w w .j a va 2 s . c om*/ */ public void getPrinters() { model.setRowCount(0); DocFlavor doc_flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintRequestAttributeSet attr_set = new HashPrintRequestAttributeSet(); PrintService[] service = PrintServiceLookup.lookupPrintServices(doc_flavor, attr_set); for (PrintService printService : service) { PrintServiceAttributeSet printServiceAttributes = printService.getAttributes(); PrinterState printerState = (PrinterState) printServiceAttributes.get(PrinterState.class); if (printService != null) { Object row[] = { new Printer(printService.getName(), true), "Online" }; model.addRow(row); } else { Object row[] = { new Printer(printService.getName(), true), "Offline" }; model.addRow(row); } } }