• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Symbols not appearing in JEditorPane

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody,

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);

scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);


Ranchers help me please.

Regards,
Bhuvana
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's actually &lt; (don't forget that semicolon at the end!) and &gt; .
 
Bhuvana Raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody,

Thanks for the reply.

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?

Please help..I need a solution to the problem.

Thanks in Advance.

Regards,
Bhuvana
[ November 08, 2006: Message edited by: Bhuvana Varsini ]
 
Bhuvana Raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

Please help me to Solve this Problem...

Regards,
Bhuvana
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if i get this right but you need to replace < for "<" only where you need it to be displayed. If you do it for all then it won't come correct
 
Bhuvana Raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.



The java applet program contains the above variable.If i replace the symbol then all the symbols gets replaced.

Am i clear?

Regards,
Bhuvana
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ">"
 
Bhuvana Raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,

Thanks for your reply.

Could you please explain me about why less than symbol not appears in JEditorPane?

Regards,
Bhuvana
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm.. see it is simple.

your string is


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.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic