Java的swing print()用法

标签 java swing printing

是否必须在 EDT(事件调度线程)上调用 java 的 swing print()?

众所周知,执行需要花费大量时间,而且在 EDT 上长时间运行的东西很痛苦。

最佳答案

简短的回答,不,打印不需要在 EDT 上进行。

这在官方教程中有介绍:How to Print Text

Printing Interactively or Non-interactively

In interactive mode a progress dialog with an abort option is shown for the duration of printing. Here is a sample of a progress dialog.

This dialog allows the user to keep track of printing progress. The progress dialog is modal when the print method is called on the event dispatch thread and non-modal otherwise. It is important that your document remain unchanged while being printed, otherwise the printing behavior is undefined. The print method ensures that your document will not be changed and disables the component for the duration of printing.

If you call the print method on the event dispatch thread in non-interactive mode, then all events including repaints will be blocked. That is why printing non-interactively on EDT is only recommended for applications with non-visible GUI.

关于Java的swing print()用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4958573/

相关文章:

javascript - 从 chrome 中的 javascript 打印 : how to know printing is done?

java - Optional 返回值为 null 时不抛异常

java - 在 Weblogic (10) 中,如何从 Java 访问节点名称?

java - 如何在android中部分改变文本的颜色

java - 如何通过 Spring 注释使用构建器模式

java - 使用 Handler 在 EDT 和其他 Java 线程之间传递信息

java - JTable排序和Jasper报告输出

Java:我是否只负责绘制(JScrollPane)视口(viewport) View 的可见区域?

Python - 将 CSV 文件作为表格打印到控制台

javascript - 向打印机发送一个包含 HTML 代码的 javascript 变量