26
27 import javax.swing.*;
28 import java.awt.*;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.WindowAdapter;
31 import java.awt.event.WindowEvent;
32 import java.awt.print.PageFormat;
33 import java.awt.print.Printable;
34 import java.awt.print.PrinterException;
35 import java.awt.print.PrinterJob;
36 import java.text.MessageFormat;
37 import java.util.concurrent.atomic.AtomicBoolean;
38 import java.lang.reflect.InvocationTargetException;
39
40 /**
41 * The {@code PrintingStatus} provides a dialog that displays progress
42 * of the printing job and provides a way to abort it
43 * <p/>
44 * Methods of these class are thread safe, although most Swing methods
45 * are not. Please see
46 * <A HREF="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency
47 * in Swing</A> for more information.
48 *
49 * @author Alexander Potochkin
50 * @since 1.6
51 */
52
53 public class PrintingStatus {
54
55 private final PrinterJob job;
56 private final Component parent;
57 private JDialog abortDialog;
58
59 private JButton abortButton;
60 private JLabel statusLabel;
61 private MessageFormat statusFormat;
62 private final AtomicBoolean isAborted = new AtomicBoolean(false);
63
64 // the action that will abort printing
65 private final Action abortAction = new AbstractAction() {
66 public void actionPerformed(ActionEvent ae) {
|
26
27 import javax.swing.*;
28 import java.awt.*;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.WindowAdapter;
31 import java.awt.event.WindowEvent;
32 import java.awt.print.PageFormat;
33 import java.awt.print.Printable;
34 import java.awt.print.PrinterException;
35 import java.awt.print.PrinterJob;
36 import java.text.MessageFormat;
37 import java.util.concurrent.atomic.AtomicBoolean;
38 import java.lang.reflect.InvocationTargetException;
39
40 /**
41 * The {@code PrintingStatus} provides a dialog that displays progress
42 * of the printing job and provides a way to abort it
43 * <p/>
44 * Methods of these class are thread safe, although most Swing methods
45 * are not. Please see
46 * <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency
47 * in Swing</A> for more information.
48 *
49 * @author Alexander Potochkin
50 * @since 1.6
51 */
52
53 public class PrintingStatus {
54
55 private final PrinterJob job;
56 private final Component parent;
57 private JDialog abortDialog;
58
59 private JButton abortButton;
60 private JLabel statusLabel;
61 private MessageFormat statusFormat;
62 private final AtomicBoolean isAborted = new AtomicBoolean(false);
63
64 // the action that will abort printing
65 private final Action abortAction = new AbstractAction() {
66 public void actionPerformed(ActionEvent ae) {
|