htmleditorkit

Q about HTMLDocument, HTMLEditorKit, and blank spaces

When I run the following code: import java.io.IOException; import java.io.Reader; import java.io.StringReader; import javax.swing.text.BadLocationException; import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; . . . St...

Where can I find a good HTMLEditorKit tutorial/reference, which actually explains how to edit HTML documents?

My intention is to edit HTML documents, including modifying existing elements, deleting elements and inserting new ones. I've read HTMLEditorKit's and related classes' documentation, as well as the relevant topic in Sun's Java Trail, yet there is very little information about actual HTML document manipulation. Most of the discussion and...

Why is Swing Parser's handleText not handling nested tags?

I need to transform some HTML text that has nested tags to decorate 'matches' with a css attribute to highlight it (like firefox search). I can't just do a simple replace (think if user searched for "img" for example), so I'm trying to just do the replace within the body text (not on tag attributes). I have a pretty straightforward HTML...

Insert HTML into the Body of an HTMLDocument

This seems like such a simple question, but I'm having such difficulty with it. Problem: I have some text to insert into an HTMLDocument. This text sometimes specifies some html as well. E.G.: Some <br />Random <b>HTML</b> I'm using HTMLEditorKit.insertHTML to insert it at a specified offset. This works fine, unless the offset is ...

Formatting text with HTML in a JEditorPane?

Hello all, I am trying to make a simple email client in Java Swing. I want to allow users to format their email in any way they want, like making some parts of the text bold, other parts italic, etc. In other words, I am trying to make a WYSIWYG editor. The formatting is done in HTML. I am using JEditorPane to display the text. I have...

Java - How do I modify a hyperlink attribute from an HTML document loaded into jEditorPane?

I am creating a start page for my application and it use jEditorPane to load an HTML document. I have it detecting hyperlink "ENTER" "EXIT" and "ACTIVATED". I know how to get an attribute of the link but how do I change an attribute. I would like to impliment a rollover effect so when ENTER is fired off it changes the links style to have...

HTMLEditorKit replacement

I have problem with HTMLEditorKit failing at parsing some webpages (in HTML3!! with NumberFormatException) or being really slow on other pages (takes up to one minute to render). Is there any good HTMLEditorKit replacement? Editor or viewer, free or commercial, for Windows and Mac OS X. Thanks ...

Using HtmlElement with HTMLDocument referencing a jEditPane that contains HTML to modify elements?

I am writing a start page for my app in HTML, and I know using jEditPane I can render HTML. I know a little about how to use HTMLEditorKit and how to convert the jEditPane document to an HTMLDocument, but how do I select and change elements on the HTML page? I see there is something called HTMLElement but I don't know how to use it in th...

Remove HTML remove aligment using Java

Hi All, I Have faces a issue with removeing alignment In HTML document. <html> <head> </head> <body> <p style="margin-top: 0" align="center"> Hello World </p> <p style="margin-top: 0" align="center"> Java World </p> </body> </html> My Issue is how to remove alignment of first paragraph with out ...

Convert HTML to plain text in Java

I need to convert HTML to plain text. My only requirement of formatting is to retain new lines in the plain text. New lines should be displayed not only in the case of < br > but other tags, eg. < tr/>, < /p> leads to a new line too. Sample HTML pages for testing are: "http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chap...