src/Print.java
// code for saving @ printing the jpanel
code for saving @ printing the jpanel
code for saving @ printing the jpanel
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setJobName("Print Data");
        job.setPrintable(new Printable(){
            public int print (Graphics pg,PageFormat pf, int pageNum) {
                if (pageNum>0){
                    return Printable.NO_SUCH_PAGE;
                }
                java.awt.Graphics2D g2 = (java.awt.Graphics2D)pg;
                g2.translate(pf.getImageableX(), pf.getImageableY());
                g2.scale(1,1);
                parentPanel.paint(g2);
                return Printable.PAGE_EXISTS;
            }
        });
            boolean ok = job.printDialog();
            if(ok){
                try{
                    job.print();
                }
                catch (PrinterException ex){}
            }
    }
private void jButton1ActionPerformed ( java . awt . event . ActionEvent evt ) { PrinterJob job = PrinterJob . getPrinterJob ( ) ; job . setJobName ( "Print Data" ) ; job . setPrintable ( new Printable ( ) { public int print ( Graphics pg , PageFormat pf , int pageNum ) { if ( pageNum > 0 ) { return Printable . NO_SUCH_PAGE ; } java . awt . Graphics2D g2 = ( java . awt . Graphics2D ) pg ; g2 . translate ( pf . getImageableX ( ) , pf . getImageableY ( ) ) ; g2 . scale ( 1 , 1 ) ; parentPanel . paint ( g2 ) ; return Printable . PAGE_EXISTS ; } } ) ; boolean ok = job . printDialog ( ) ; if ( ok ) { try { job . print ( ) ; } catch ( PrinterException ex ) { } } }
code for saving @ printing the jpanel
code for saving @ printing the jpanel
//GEN-FIRST:event_jButton1ActionPerformed