Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PrinterJob job = PrinterJob.getPrinterJob();
- job.setJobName("test");
- job.setPrintable (new Printable() {
- @Override
- public int print(Graphics pg, PageFormat pf, int pageNum) throws PrinterException{
- if (pageNum > 0){
- return Printable.NO_SUCH_PAGE;
- }
- Graphics2D g2 = (Graphics2D) pg;
- g2.translate(pf.getImageableX(), pf.getImageableY());
- jPanel1.print(g2);
- // jTable1.print(JTable.PrintMode.FIT_WIDTH, null, null);
- return Printable.PAGE_EXISTS;
- }
- });
- boolean ok = job.printDialog();
- if (ok) {
- try {
- job.print();
- } catch (PrinterException ex) {
- }
- }
Add Comment
Please, Sign In to add comment