Java's swing print() usage

后端 未结 2 1472
無奈伤痛
無奈伤痛 2021-01-19 18:57

Does java\'s swing print() have to be called on the EDT (event dispatch thread)?

It is taking an extended amount of time to execute and long running things being on

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 19:42

    Be aware though, JTextComponent is the only Swing component that can be printed on a background thread, by using its dedicated print methods. The print method inherited from JComponent is not thread safe.

    In general: Swing is single threaded except when stated otherwise. JTextComponent's dedicated print method explicitly states it is thread safe:

    http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#print(java.text.MessageFormat,%20java.text.MessageFormat,%20boolean,%20javax.print.PrintService,%20javax.print.attribute.PrintRequestAttributeSet,%20boolean)

提交回复
热议问题