Package javax.swing.text

Examples of javax.swing.text.EditorKit


    /**
     * Given some html, extracts its text.
     */
    public static String extractTextFromHTML(String html) {
        try {
            EditorKit kit = new HTMLEditorKit();
            Document doc = kit.createDefaultDocument();

            // The Document class does not yet handle charset's properly.
            doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);

            // Create a reader on the HTML content.
            Reader rd = new StringReader(html);

            // Parse the HTML.
            kit.read(rd, doc, 0);

            //  The HTML text is now stored in the document
            return doc.getText(0, doc.getLength());
        } catch (Exception e) {
        }
View Full Code Here


       * @param e - the JEditorPane to get the HTMLEditorKit from.
       * @return the HTMLEditorKit
       */
      protected HTMLEditorKit getHTMLEditorKit(JEditorPane e)
      {
        EditorKit d = e.getEditorKit();
        if (d instanceof HTMLEditorKit)
          return (HTMLEditorKit) d;
        throw new IllegalArgumentException("EditorKit is not a HTMLEditorKit.");
      }
View Full Code Here

        FileSystem fileSystem = FileUtil.createMemoryFileSystem();
        try {
            FileObject file = fileSystem.getRoot().createData("template", extension);
            DataObject data = DataObject.find(file);
            if (data != null) {
                EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType);
                editorPane.setEditorKit(kit);
                editorPane.getDocument().putProperty(Document.StreamDescriptionProperty, data);
                DialogBinding.bindComponentToFile(file, 0, 0, editorPane);
                editorPane.setText(" ");
            }
View Full Code Here

//      return null;
//    }
//  }

  public EditorKit getEditorKitForContentType( String type ) {
    final EditorKit kit = super.getEditorKitForContentType( overrideContentType == null ? type : overrideContentType );
//    System.out.println( "getEditorKitForContentType( " + type + " ) => " + kit );
    return kit;
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.EditorKit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.