Well, I'm doing pretty good with my WebChat application, but I was thinking to add some smileys!

At first, I would like the app to auto detect the smileys in standard form from a given string and place the image in its place, but I came across the problem: how can I add images to a specific/moving place in a jtextarea?

Also, I can easily write something that will "look for" something like ":)", but then, how would I tell the jtextarea to place a smiley there instead (maybe add 1 word at a time with jtextarea.append(word)?)

In that case, I would need to do an append like function on an image?

Not sure if its possible, but I'm throwing it out there.. lol

I came across this post: http://www.daniweb.com/forums/thread210869.html
Which said many Swing components can take html tags.

I'm not too great at the whole HTML thing, but although JTextAreas are swing components, I do not believe they fall into this category.

here is what I've tried regarding HTML:

import java.awt.Dimension;
import java.util.Scanner;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

class test extends JFrame {
	JTextArea area;
	Scanner scan;
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				new test();
	public test() {
		scan = new Scanner(System.in);
		area = new JTextArea();
		JScrollPane sp = new JScrollPane(area);
		sp.setPreferredSize(new Dimension(300,300));
	public String replaceSmileys(String line) {
		if (line.contains(":)"))
			return line.replace(":)", "<html><b><u>T</u>est</b></html>");
			return line;

That should have replaced ":)" with Test, instead it just kept the syntax. I believe this would work with JLabels? I'm just hoping theres a better way so I dont reinvent the JTextArea.. lol