The JEditorPane doesn't displays < symbol when the content type is "text/html".Please go through this code and provide me a solution.
editor = new javax.swing.JEditorPane(); editor.setContentType("text/html"); editor.setText("<html><body>checking less < than greater > than symbols </body></html> ");
scrollPane = new JScrollPane(editor); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
editor.setText("<html><body>checking less & lt than greater & gt than symbols </body></html> ");
[edit] the software converts it to the symbol, so I've added a space & lt//remove the space & gt//remove the space [ November 08, 2006: Message edited by: Michael Dunn ]
Ernest Friedman-Hill
,
author and iconoclast
staff
Actually, i am sending content which is in HTML format, from Webpage to applet code. The applet code contains JEditorPane code to display the html content as such. If i replace "<" to & lt ;(without space) then the tags too get converted.
While returning back the content, it is viewed with tags in the JEditorpane.
Could anyone please explain me why"<" symbol is appearing in JEditorPane when the contenttype is text/html?
Hi Bhuvana, HTML is very loosely typed language. I understand what you are facing and what i meant is the you should be looking at replacing those < > signs in where you are getting them from and not after reading them.
If it is possible well and fine, else there are options 1. You write a full fledged HTML parser that finds out the right tags (in that process you will go mad) 2. find out some patterns that can identify the < > signs in your text like in here you can replace " > " instead of ">"
Now suppose that you are the program then how do you know which symbols are to be taken for tags andwhich ones for symbols?? that is why ideally your code must have been
It is this precise reason why if you write ;lt in this forum that it will be displayed as a less than sign.
Post by:autobot
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, the permaculture playing cards