Coloring the text Messages

I want to build a simple program which uses three text boxes. text1, text2 and text3. When i write in text1 and press enter it should show the text in text3 with red color and when i write in text2 and press enter it should show in text3 in blue color. Something like a chat application. can anyone guide me how to do it. I do not want to use a swing class. just a textpane or some other basic control. pls help. thanks in advance.

Dear Sir,
Please find herewith some code snippet for your help.
JTextField tf1=new JTextField(10);
JTextField tf2=new JTextField(10);
JTextField tf3=new JTextField(10);
tf1.addKeyListener(new Text1());
tf2.addKeyListener(new Text2());
class Text1 extends KeyAdapter //inner class for event listening
public void keyPressed(KeyEvent ke)
if(ke.getKeyCode()==KeyEvent.VK_ENTER)
tf3.setForeground(Color.red);
tf3.setText(tf1.getText());
class Text2 extends KeyAdapter //inner class for event listening
public void keyPressed(KeyEvent ke)
if(ke.getKeyCode()==KeyEvent.VK_ENTER)
tf3.setForeground(Color.blue);
tf3.setText(tf1.getText());

Similar Messages

Maybe you are looking for

  • Cloud Synchronisation

    Hallo, habe mal ein grundsätzliche Frage zu den Synchronisationsmöglichkeiten in der Cloud: Als ich mich das erste mal über die Cloud bei Adobe erkundigt habe, wurde mir gesagt, es sei kein Problem Dateien zwischen unterschiedlichen Nutzern zu synchr

  • IPod shows up as disk but not in iTunes on Yosemite

    Hi, I have an iPod classic, previously owned by a different family member on a different library. I wanted to erase and get my own content on. The problem is that it does come up as a disk in Finder, but not in iTunes. I have used on various other co

  • Picture hyperlinks not working when published? Please help....

    Some of the hyperlinks to my pictures do not work when I publish to my folder. I´ve tried to empty Safaris cache but it still doesn´t work. Please help me, pretty urgent....

  • Enable Usage Rights to Multiple Documents at the same time

    I was wondering if there is a way to add Enable Usage Rights to Multiple Documents at the Same Time?

  • Portal connection test for connector giving error.

    Hi All, In the portal , No connection to system SAP_BW found: com.sapportals.connector.connection.ConnectionFailedException: Connection Failed: A nested exception occurred. Could not initialize physical connection. Connection Failed: A nested excepti