53 import java.awt.print.Printable;
54 import java.awt.print.PrinterException;
55
56 import javax.print.PrintService;
57 import javax.print.attribute.PrintRequestAttributeSet;
58
59 import java.text.*;
60 import java.text.AttributedCharacterIterator.Attribute;
61
62 import javax.swing.*;
63 import javax.swing.event.*;
64 import javax.swing.plaf.*;
65
66 import javax.accessibility.*;
67
68 import javax.print.attribute.*;
69
70 import sun.awt.AppContext;
71
72
73 import sun.misc.ManagedLocalsThread;
74 import sun.swing.PrintingStatus;
75 import sun.swing.SwingUtilities2;
76 import sun.swing.text.TextComponentPrintable;
77 import sun.swing.SwingAccessor;
78
79 /**
80 * <code>JTextComponent</code> is the base class for swing text
81 * components. It tries to be compatible with the
82 * <code>java.awt.TextComponent</code> class
83 * where it can reasonably do so. Also provided are other services
84 * for additional flexibility (beyond the pluggable UI and bean
85 * support).
86 * You can find information on how to use the functionality
87 * this class provides in
88 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html">General Rules for Using Text Components</a>,
89 * a section in <em>The Java Tutorial.</em>
90 *
91 * <dl>
92 * <dt><b>Caret Changes</b>
93 * <dd>
2336 throw new RuntimeException(e);
2337 } catch (ExecutionException e) {
2338 Throwable cause = e.getCause();
2339 if (cause instanceof Error) {
2340 throw (Error) cause;
2341 }
2342 if (cause instanceof RuntimeException) {
2343 throw (RuntimeException) cause;
2344 }
2345 throw new AssertionError(cause);
2346 }
2347 }
2348 }
2349 }
2350 };
2351
2352 if (! interactive || isHeadless) {
2353 runnablePrinting.run();
2354 } else {
2355 if (isEventDispatchThread) {
2356 new ManagedLocalsThread(runnablePrinting).start();
2357 printingStatus.showModal(true);
2358 } else {
2359 printingStatus.showModal(false);
2360 runnablePrinting.run();
2361 }
2362 }
2363
2364 //the printing is done successfully or otherwise.
2365 //dialog is hidden if needed.
2366 try {
2367 futurePrinting.get();
2368 } catch (InterruptedException e) {
2369 throw new RuntimeException(e);
2370 } catch (ExecutionException e) {
2371 Throwable cause = e.getCause();
2372 if (cause instanceof PrinterAbortException) {
2373 if (printingStatus != null
2374 && printingStatus.isAborted()) {
2375 return false;
2376 } else {
|
53 import java.awt.print.Printable;
54 import java.awt.print.PrinterException;
55
56 import javax.print.PrintService;
57 import javax.print.attribute.PrintRequestAttributeSet;
58
59 import java.text.*;
60 import java.text.AttributedCharacterIterator.Attribute;
61
62 import javax.swing.*;
63 import javax.swing.event.*;
64 import javax.swing.plaf.*;
65
66 import javax.accessibility.*;
67
68 import javax.print.attribute.*;
69
70 import sun.awt.AppContext;
71
72
73 import sun.swing.PrintingStatus;
74 import sun.swing.SwingUtilities2;
75 import sun.swing.text.TextComponentPrintable;
76 import sun.swing.SwingAccessor;
77
78 /**
79 * <code>JTextComponent</code> is the base class for swing text
80 * components. It tries to be compatible with the
81 * <code>java.awt.TextComponent</code> class
82 * where it can reasonably do so. Also provided are other services
83 * for additional flexibility (beyond the pluggable UI and bean
84 * support).
85 * You can find information on how to use the functionality
86 * this class provides in
87 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html">General Rules for Using Text Components</a>,
88 * a section in <em>The Java Tutorial.</em>
89 *
90 * <dl>
91 * <dt><b>Caret Changes</b>
92 * <dd>
2335 throw new RuntimeException(e);
2336 } catch (ExecutionException e) {
2337 Throwable cause = e.getCause();
2338 if (cause instanceof Error) {
2339 throw (Error) cause;
2340 }
2341 if (cause instanceof RuntimeException) {
2342 throw (RuntimeException) cause;
2343 }
2344 throw new AssertionError(cause);
2345 }
2346 }
2347 }
2348 }
2349 };
2350
2351 if (! interactive || isHeadless) {
2352 runnablePrinting.run();
2353 } else {
2354 if (isEventDispatchThread) {
2355 new Thread(null, runnablePrinting,
2356 "JTextComponentPrint", 0, false ).start();
2357 printingStatus.showModal(true);
2358 } else {
2359 printingStatus.showModal(false);
2360 runnablePrinting.run();
2361 }
2362 }
2363
2364 //the printing is done successfully or otherwise.
2365 //dialog is hidden if needed.
2366 try {
2367 futurePrinting.get();
2368 } catch (InterruptedException e) {
2369 throw new RuntimeException(e);
2370 } catch (ExecutionException e) {
2371 Throwable cause = e.getCause();
2372 if (cause instanceof PrinterAbortException) {
2373 if (printingStatus != null
2374 && printingStatus.isAborted()) {
2375 return false;
2376 } else {
|