//...Printer printer = new Printer(MyDialog);if (printer.setPage() && printer.setPrinter()) { printer.print();}//...