Skip to main content

changing text attributes in document in JTextPane

2 replies [Last post]
yurazlin
Offline
Joined: 2004-04-07

i have performance issue in that case. i have a doc having about several handreds of kb of text.

when i try to color a doc with particular scheme using setCharacterAttributes, say, highlight keywords and grey some other words it takes sooo long...

i looked through the code and found that each call to setCharacterAttributes contains synchronization locks. i think it's a reason of perf degradation. so i gave up changing text attrs and hignlight what i need just painting over JTextPane. but as for me that's bad ;(

is there a "fair way" to change character attributes of Document contatining text of ~500kb in acceptable time?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
idk
Offline
Joined: 2005-01-12

Hello there,

There are other ways to have colored text except changing the characterAttributes. One way of doing this might be implementing your own javax.swing.text.View. This view would use colors based on logic you want.

-Igor

yurazlin
Offline
Joined: 2004-04-07

thanx a lot for your input. i'll try this.