Results 1 to 1 of 1
- 03-07-2011, 08:16 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 19
- Rep Power
- 0
JEditorPane / JTextPane help needed!
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(); } }
Similar Threads
-
JEditorPane + MouseWheel
By Moncleared in forum New To JavaReplies: 2Last Post: 10-09-2010, 01:27 AM -
CSS2/3 in JEditorPane?
By DigitalMan in forum AWT / SwingReplies: 1Last Post: 04-02-2010, 10:48 AM -
Javascript in JEditorpane
By Narayan15 in forum AWT / SwingReplies: 1Last Post: 03-27-2009, 05:49 PM -
JEditorPane Example
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:47 PM -
JEditorPane
By drmmr11 in forum Java AppletsReplies: 0Last Post: 08-02-2007, 06:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks