• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 2701
10
  • 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: 20822
68
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!