>>412の続き
<class PrinterActionListener>
class PrinterActionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);

try{
if (service != null) {
DocPrintJob job = service.createPrintJob();
DocAttributeSet das = new HashDocAttributeSet();
Doc Pdoc = new SimpleDoc(new Mycomponent(),flavor,das);
job.print(Pdoc,pras);
Thread.sleep(10000);
}}catch(Exception eee){
System.out.println(eee);
}}}