File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextPane "text/html"" Watch "JTextPane "text/html"" New topic

JTextPane "text/html"

selvas kumars
Ranch Hand

Joined: Jan 06, 2001
Posts: 115
If i set textPane.setContentType("text/html"), textpane shows as a html editor.But when i call a getText() it gives
an html document in a string format.I want only the text(with out html tags)??How to acheive this??
Thanks & Regards,
kshitij raval

Joined: Oct 20, 2001
Posts: 15
Well I could not find any solution to this from the API. But I have thought of a solution, let me know if this turns out to be helpful to you. Also let me know if you have found a solution already.
I have added KeyListener to JTextPane then in the keyTyped() method I added the characters typed to a String object. Whenever I wanted just the typed matter, I would refer to that String object.
String typedMatter="";
JTextPane jtp = new JTextPane();
public void keyTyped(KeyEvent ke){
typedMatter += ke.getKeyChar();
Kshitij Raval.

[This message has been edited by kshitij raval (edited October 20, 2001).]
I agree. Here's the link:
subject: JTextPane "text/html"
It's not a secret anymore!