Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a exercise about chat client server, so i don't have lot of java,
I am coding for chat private. I have some problem which need your help.
1. I have a textArea to contain chat message, I want set font and color to user name part the same as:

ga_con: hello Tom.
tiger: hi marry.

2. I have a list friend and display them to main chat(the same yahoo) but i don't know which best control to display them and their icon.in this case we are can change status of a friend from offline to online when this friend log in(online) by change their icon. this control must allow m open private chat window when i double click on nay friend.

the hope that receive your help soon.

P/S: please give some code line

thank in advance
Posted
Updated 3-Dec-12 8:03am
v3

1 solution

First of all, this is a classic homework task. So I would like to leave the coding to you.

I would define the colors, maybe selectable via a JcolorChooser Dialog.
These colors need to be applied to the text. To make that simpler, I would Not think of a JTextArea but of a Scrollpane, that I add Labels to.

These Labels should be custom. They would hold the colors and apply one or the other to the Label:

Java
public class CustomLabel extend JLabel{

private final Color oColor1, oColor2;

public CustomLabel(){
  super(strText);
  // set colors
  this.ignition();
}

private void ignition(){
  this.setForeground(oColor1);
}
}


http://www.leepoint.net/notes-java/GUI/components/10labels/12labelfontcolor.html[^]

How to use Scrollpane[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900