1 2 import java.awt.*; 3 import java.awt.event.*; 4 import javax.swing.*; 5 import javax.print.*; 6 7 void jButton2_actionPerformed(ActionEvent e) { 8 DefaultListModel model = new DefaultListModel(); 9 JList jList1 = new JList(model); 10 jList1.setToolTipText(""); 11 jList1.setBounds(new Rectangle(136, 34, 191, 156)); 12 jpnlMain.add(jList1, null); 13 // list printers on your pc 14 PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); 15 for (int i=0; i<services.length; i++) { 16 model.add(i, services[i].getName()); 17 } 18 }