Hello folks, i need your help! :eek:
So i decided to make SIMPLE program that includes emoticons etc on text area. I found out way to make it, the way i did (using html in jeditor/jtextpane) Theres still many problems with it. I cant figure out how i can make it so it dls the images from my computer, not internet. whenever i change the url to path to image/image name(the way it works on other apps) it just stays blank even if i checked if the path was right etc. I dont want it to load the images from internet everytime instead keep them stored somewhere. Also can you advice with better way to check if theres :) or so typed than listening every keystrokes and after that do what it have to. I hope theres enought information for you guys. Basically the problem is that i am unable to load images from my computers memory and i need better way to check for ":)" typed etc.
Java Code:
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;

import javax.swing.*;
class JEditorTest{
	static JTextPane jtp;
	public static void main(String args[]){
		JFrame frame = new JFrame("test");
		frame.setVisible(true);
		jtp = new JTextPane();
		jtp.setContentType("text/html");
		jtp.setText("<html> <head></head> <body> <h1> I do work </h1> <p> me too </p> <img src=\"http://www.java-forums.org/images/smilies/smile.gif\"> </img> </body> </html>");
		jtp.addKeyListener(new KeyListener(){

			@Override
			public void keyPressed(KeyEvent arg0) {
				if(jtp.getText().contains(":)")){
					System.out.println(new File("duke.png").getAbsolutePath());
					jtp.setText(jtp.getText().replace(":)", "<img src=\"http://www.java-forums.org/images/smilies/smile.gif\"> </img>"));
				}
				
			}

			@Override
			public void keyReleased(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void keyTyped(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		JScrollPane jstp = new JScrollPane(jtp);
		frame.setContentPane(jstp);
		frame.pack();
	}
}