Click here to Skip to main content
12,824,299 members (40,839 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java
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 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 3-Dec-12 6:39am
Updated 3-Dec-12 9:03am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:

public class CustomLabel extend JLabel{

private final Color oColor1, oColor2;

public CustomLabel(){
  // set colors

private void ignition(){

How to use Scrollpane[^]

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100