Click here to Skip to main content
11,634,486 members (72,801 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java Homework
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 3-Dec-12 5:39am
ngthtra1.4K
Edited 3-Dec-12 8:03am
TorstenH.34.8K
v3

1 solution

Rate this: bad
good
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(){
  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[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 8,758
1 Sergey Alexandrovich Kryukov 8,264
2 Mika Wendelius 6,755
3 F-ES Sitecore 2,344
4 Suvendu Shekhar Giri 2,095


Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
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