是否必须在 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/