Changing Colors for certain string in JTextArea
843807Apr 21 2010 — edited Apr 21 2010Hello guys! Once again I need your help.
I'm trying to create a simple chat in java, and I need to know how to change colors of just certain strings in the JTextArea.
For example, via constructor I take some username, for Example "Toni" and when I type something in my chat , for example "hello" it will write in JTextArea " Toni: hello ".
So, 3 Questions:D
1) How can I change that this String that takes username has it own color , so every time i write something my username part (Toni) is red and rest of the text is black by default.
{color:#ff0000}Toni{color}: hello
2)I want to differentiate my messages from incoming messages; so what options should I set, or better how should I do that my messages are like in previous example and messages from the other person is in different color, example:
{color:#ff0000}Toni{color}: Hello
{color:#3366ff}Mark: Hi, how are you?
{color}3) I know how to get current time, but I'd like to know how to write out transparent time, for example when I send some message that it says with a bit transparent letters "message sent at 10:04".
Guys, thank you very much in advance, and sorry to bother you.
Cheers from Croatia.
Toni