This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane "lag" (not time issue, color issue)  RSS feed

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The code under "//later" is called every time you push enter. It takes text posted in a JTextArea and spits it out. The only problem I am having with it is that the color only shows up AFTER you push the next line... Why is it doing this and how do you fix it?
Thanks,
John Price aka cc11rocks
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It takes text posted in a JTextArea and spits it out.


A JTextArea doesn't support attributes.

Post your SSCCE that demonstrates the problem.
 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code shows a JTextPane is used so that would make more sense.

To add colours while you're typing you should use a DocumentListener. That will listen to events for new text, removed text and replaced text.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!