/* * ConcreteSplitViewer program for analazing splits. * Copyright (C) 2006-2007 Mytinski Leonid (Leonid.Mytinski@gmail.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ /* * PreviewDialog.java * * Created on 16 Декабрь 2007 г., 19:32 */ package ru.concretesoft.concretesplitviewer; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import javax.swing.JComponent; /** * * @author Mytinski Leonid */ public class PrintPreviewDialog extends javax.swing.JDialog { private JComponent chartComponent; private JComponent listComponent; /** Creates new form PreviewDialog */ public PrintPreviewDialog(java.awt.Frame parent, boolean modal, JComponent chartComponent, JComponent listComponent) { super(parent, modal); this.chartComponent = chartComponent; this.listComponent = listComponent; initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jPanel1 = new PrintingPreviewPanel(chartComponent, listComponent); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(new java.awt.GridBagLayout()); jPanel1.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(jPanel1, gridBagConstraints); jButton1.setText("Print"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PrintAction(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; getContentPane().add(jButton1, gridBagConstraints); jButton2.setText("Close"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CloseAction(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; getContentPane().add(jButton2, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void CloseAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseAction setVisible(false); }//GEN-LAST:event_CloseAction private void PrintAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintAction PrintUtilities pU = new PrintUtilities(jPanel1); PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintable(pU); if (printJob.printDialog()) try { printJob.print(); } catch(PrinterException pe) { System.out.println("Error printing: " + pe); } setVisible(false); }//GEN-LAST:event_PrintAction // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JPanel jPanel1; // End of variables declaration//GEN-END:variables }