htmleditorkit

JEditorPane, HTMLEditorKit - custom action inserting custom tag

匆匆过客 提交于 2019-12-07 10:04:21
问题 I'm faithing with JEditorPane . I need simple editor. I've solved the problem with loading and modified HTML containing custom (two) tags (see my older post). It displays the document properly and I can even edit it now. I can write text, delete either characters or my custom elements. I won a battle, but haven't won the war. The next step is regrettably very problematical too. I'm unable to insert my custom tags. I have a custom action: import my.own.HTMLEditorKit; //extends standard

Access/Change JEditorPane's html loaded elements + HTMLEditorKit problem with Unicode (Java)

纵饮孤独 提交于 2019-12-07 08:07:00
问题 that's going to be a long question so bear with me :) My Application I'm developing a Java (with JFrame GUI) desktop application that does the following: Scan (.txt) files. Parses some numbers from these files, performs some calculations on them and finally stores the results in String variables. Outputs these numbers in a special (table) format. (Note: the format includes some Unicode (Arabic) Characters.) Problem The first two parts went smoothly. However when I came to the 3th part (the

how to retrieve TITLE of a HTML with the help of HTMLEditorKit

白昼怎懂夜的黑 提交于 2019-12-05 20:39:14
I want to retrieve TITLE attribute with the help of java's HTMLEditorKit ? this what I've written but it will return "null" all the time and inspector in eclipse doesn't help that much ! import java.io.FileReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import javax.swing.text.MutableAttributeSet; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.parser.ParserDelegator; public class testHTML { public static void main(String args[]) throws Exception { Reader reader = new

JEditorPane, HTMLEditorKit - custom action inserting custom tag

一世执手 提交于 2019-12-05 14:39:08
I'm faithing with JEditorPane . I need simple editor. I've solved the problem with loading and modified HTML containing custom (two) tags (see my older post ). It displays the document properly and I can even edit it now. I can write text, delete either characters or my custom elements. I won a battle, but haven't won the war. The next step is regrettably very problematical too. I'm unable to insert my custom tags. I have a custom action: import my.own.HTMLEditorKit; //extends standard HTMLEditorKit import my.own.HTMLDocument; //extends standard HTMLDocument class InsertElementAction extends

Convert HTML to plain text in Java

妖精的绣舞 提交于 2019-12-04 02:14:42
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, e.g. <tr/> , </p> leads to a new line too. Sample HTML pages for testing are: http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter09/scannerConsole.html http://www.javadb.com/write-to-file-using-bufferedwriter Note that these are only random URLs. I have tried out various libraries (JSoup, Javax.swing, Apache utils) mentioned in the answers to this StackOverflow question to convert HTML to

HTML wrapped String creates a unwanted new line in JtextPane output

假装没事ソ 提交于 2019-12-02 07:39:08
问题 When I concentrate a String with a HTML formatted string, and output the String to a JTextPane with a HTMLEditor kit, every appended String wrapped in the HTML tags appears to cause a new line: // Set the HTML Editor kit for JTExtPAne jtextPane.setEditorKit(new HTMLEditorKit()); String saveCurrentSentenceState = "Some String"; String newWord = "new word"; // wrap this in HTML tags // Create a HTML String String appendHTML = "<html><font color=\"red\">"+newWord+"<</font>"; // Concatenate with

JTextPane - Bullet with HTMLEditorKit list not rendering correctly unless I do setText(getText()) and repaint

烂漫一生 提交于 2019-12-01 14:06:23
I have: JTextPane jtextPane = new JTextPane(); jtextPane.setEditorKit(new HTMLEditorKit()); ... Then later I try to add an unordered list button to the toolbar such that the action is: Action insertBulletAction = HTMLEditorKit.InsertHTMLTextAction ("Bullets", "<ul><li> </li></ul>", HTML.Tag.P, HTML.Tag.UL); JButton insertBulletJButton = new JButton(insertBulletAction); And this does include the proper code if I take a dump of the html that's generated. However it will be rendered really badly, as in not even close to reasonable as illustrated below: However if I do: jtextPane.setText(jtextPane

JTextPane - Bullet with HTMLEditorKit list not rendering correctly unless I do setText(getText()) and repaint

怎甘沉沦 提交于 2019-12-01 13:21:27
问题 I have: JTextPane jtextPane = new JTextPane(); jtextPane.setEditorKit(new HTMLEditorKit()); ... Then later I try to add an unordered list button to the toolbar such that the action is: Action insertBulletAction = HTMLEditorKit.InsertHTMLTextAction ("Bullets", "<ul><li> </li></ul>", HTML.Tag.P, HTML.Tag.UL); JButton insertBulletJButton = new JButton(insertBulletAction); And this does include the proper code if I take a dump of the html that's generated. However it will be rendered really badly