javax.swing.text.html.HTMLEditorKit.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中javax.swing.text.html.HTMLEditorKit.<init>()方法的一些代码示例,展示了HTMLEditorKit.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTMLEditorKit.<init>()方法的具体详情如下:
包路径:javax.swing.text.html.HTMLEditorKit
类名称:HTMLEditorKit
方法名:<init>

HTMLEditorKit.<init>介绍

暂无

代码示例

代码示例来源:origin: spotbugs/spotbugs

  1. public static void convertHtmlToText(Reader reader, Writer writer) throws IOException, BadLocationException {
  2. EditorKit kit = new HTMLEditorKit();
  3. HTMLDocument doc = new HTMLDocument();
  4. kit.read(reader, doc, 0);
  5. HTMLtoPlainTextWriter2 x = new HTMLtoPlainTextWriter2(writer, doc);
  6. x.write();
  7. writer.close();
  8. }

代码示例来源:origin: stackoverflow.com

  1. JTextPane text_panel = new JTextPane();
  2. HTMLEditorKit kit = new HTMLEditorKit();
  3. HTMLDocument doc = new HTMLDocument();
  4. text_panel.setEditorKit(kit);
  5. text_panel.setDocument(doc);
  6. kit.insertHTML(doc, doc.getLength(), "<b>hello", 0, 0, HTML.Tag.B);
  7. kit.insertHTML(doc, doc.getLength(), "<font color='red'><u>world</u></font>", 0, 0, null);

代码示例来源:origin: stackoverflow.com

  1. JEditorPane editorPane =
  2. new JEditorPane(new HTMLEditorKit().getContentType(),text);
  3. editorPane.setText(text);
  4. Font font = new Font("Segoe UI", Font.PLAIN, 24));
  5. String bodyRule = "body { font-family: " + font.getFamily() + "; " +
  6. "font-size: " + font.getSize() + "pt; }";
  7. ((HTMLDocument)editorPane.getDocument()).getStyleSheet().addRule(bodyRule);

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

  1. public FixedHeightPane () {
  2. super ();
  3. setEditable(false);
  4. HTMLEditorKit htmlkit = new HTMLEditorKit();

代码示例来源:origin: stackoverflow.com

  1. editorPane.setContentType("text/html");
  2. HTMLEditorKit kit = new HTMLEditorKit();
  3. editorPane.setEditorKit(kit);
  4. File cssfile = new File("src/Assets/code.css");
  5. StyleSheet styleSheet = kit.getStyleSheet();
  6. styleSheet.importStyleSheet(cssfile.toURI().toURL());
  7. editorPane.setText("<html><head></head><body><pre></pre></body></html>");

代码示例来源:origin: fr.ifremer/isis-fish

  1. protected void init() {
  2. String REGISTER_KEY_URL = "https://labs.libre-entreprise.org/account/editsshkeys.php";
  3. String DOC_URL = "http://isis-fish.labs.libre-entreprise.org/isis-fish/v3/user/addSshKey.html";
  4. StringBuilder builder = new StringBuilder();
  5. builder.append("<a href='").append(DOC_URL).append("'>");
  6. builder.append(t("isisfish.vcs.howto.save.key")).append("</a><br/>");
  7. builder.append("<a href='").append(REGISTER_KEY_URL).append("'>");
  8. builder.append(t("isisfish.vcs.save.key")).append("</a>");
  9. helpEditor.setEditorKit(new HTMLEditorKit());
  10. helpEditor.setText(builder.toString());
  11. }

代码示例来源:origin: stackoverflow.com

  1. final HTMLEditorKit htmlKit = new HTMLEditorKit();
  2. final JTextPane textPane = new JTextPane( );
  3. textPane.setEditorKit(htmlKit);
  4. textPane.setEditable(true);
  5. JScrollPane scrollPane = new JScrollPane( textPane );
  6. Document doc = textPane.getDocument();
  7. System.out.println(doc.getClass().getName()); // It's an HTML Document

代码示例来源:origin: igniterealtime/Spark

  1. /**
  2. * Creates a new CoBrowser object to be used with the specifid ChatRoom.
  3. */
  4. public HTMLViewer() {
  5. final JPanel mainPanel = new JPanel();
  6. browser = new JEditorPane();
  7. browser.setEditorKit(new HTMLEditorKit());
  8. setLayout(new GridBagLayout());
  9. this.add(mainPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
  10. }

代码示例来源:origin: freeplane/freeplane

  1. public HtmlProcessor(final String input){
  2. final HTMLEditorKit kit = new HTMLEditorKit();
  3. doc = kit.createDefaultDocument();
  4. try {
  5. final int defaultDocumentLength = doc.getLength();
  6. kit.read(new StringReader(input), doc, defaultDocumentLength);
  7. } catch (Exception e) {
  8. }
  9. }
  10. public String htmlSubstring(int pos, int length){

代码示例来源:origin: net.java.abeille/abeille

  1. public void createCreditsPanel() {
  2. JEditorPane editor = (JEditorPane) m_view.getComponentByName(AboutViewNames.ID_CREDITS);
  3. editor.setEditorKit(new javax.swing.text.html.HTMLEditorKit());
  4. try {
  5. java.net.URL url = AboutView.class.getClassLoader().getResource("com/jeta/swingbuilder/resources/help/credits.htm");
  6. editor.setPage(url);
  7. editor.setEditable(false);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. }
  11. }

代码示例来源:origin: nroduit/Weasis

  1. public static HTMLEditorKit buildHTMLEditorKit(JComponent component) {
  2. Objects.requireNonNull(component);
  3. HTMLEditorKit kit = new HTMLEditorKit();
  4. StyleSheet ss = kit.getStyleSheet();
  5. ss.addRule("body {font-family:sans-serif;font-size:12pt;background-color:#" //$NON-NLS-1$
  6. + Integer.toHexString((component.getBackground().getRGB() & 0xffffff) | 0x1000000).substring(1) + ";color:#" //$NON-NLS-1$
  7. + Integer.toHexString((component.getForeground().getRGB() & 0xffffff) | 0x1000000).substring(1)
  8. + ";margin:3;font-weight:normal;}"); //$NON-NLS-1$
  9. return kit;
  10. }

代码示例来源:origin: stackoverflow.com

  1. String rtf = [your document rich text];
  2. BufferedReader input = new BufferedReader(new StringReader(rtf));
  3. RTFEditorKit rtfKit = new RTFEditorKit();
  4. StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
  5. rtfEdtrKt.read( input, doc, 0 );
  6. input.close();
  7. HTMLEditorKit htmlKit = new HTMLEditorKit();
  8. StringWriter output = new StringWriter();
  9. htmlKit.write( output, doc, 0, doc.getLength());
  10. String html = output.toString();

代码示例来源:origin: org.freehep/freehep-graphicsio-tests

  1. public TestHTML(String[] args) throws Exception {
  2. super(args);
  3. setName("HTML");
  4. text = "&lt;Vector<sup><b>Graphics</b></sup> &amp; Adapter<i><sub>Card</sub></i> "
  5. + "= e<sup>x<sup>2</sup>y<sup>3</sup></sup>&gt;";
  6. JEditorPane pane = new JEditorPane();
  7. pane.setContentType("text/html");
  8. pane.setEditorKit(new HTMLEditorKit());
  9. pane.setText(text);
  10. pane.setEditable(false);
  11. add(pane);
  12. }

代码示例来源:origin: stackoverflow.com

  1. EditorKit kit = new HTMLEditorKit();
  2. HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument();
  3. doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
  4. kit.read(reader, doc, 0);
  5. HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A);
  6. while (it.isValid())
  7. {
  8. SimpleAttributeSet s = (SimpleAttributeSet)it.getAttributes();
  9. String href = (String)s.getAttribute(HTML.Attribute.HREF);
  10. System.out.println( href );
  11. it.next();
  12. }

代码示例来源:origin: stackoverflow.com

  1. JEditorPane jEditorPane = new JEditorPane();
  2. HTMLEditorKit kit = new HTMLEditorKit();
  3. StyleSheet styleSheet = kit.getStyleSheet();
  4. styleSheet.addRule("A {color:red}"); //change links to red
  5. jEditorPane.setEditorKit(kit);

代码示例来源:origin: com.google.code.findbugs/findbugs

  1. public static void convertHtmlToText(Reader reader, Writer writer) throws IOException, BadLocationException {
  2. EditorKit kit = new HTMLEditorKit();
  3. HTMLDocument doc = new HTMLDocument();
  4. kit.read(reader, doc, 0);
  5. HTMLtoPlainTextWriter2 x = new HTMLtoPlainTextWriter2(writer, doc);
  6. x.write();
  7. writer.close();
  8. }

代码示例来源:origin: stackoverflow.com

  1. HTMLDocument doc = new HTMLDocument();
  2. HTMLEditorKit kit = new HTMLEditorKit();
  3. jEditorPane.setDocument(doc);
  4. jEditorPane.setEditorKit(kit);
  5. kit.insertHTML(doc, doc.getLength(), "<label> This label will be inserted inside the body directly </label>", 0, 0, null);
  6. kit.insertHTML(doc, doc.getLength(), "<br/>", 0, 0, null);
  7. kit.insertHTML(doc, doc.getLength(), putYourVariableHere, 0, 0, null);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject

  1. /** Creates new form SelectModePanel */
  2. public SelectModePanel(SelectModeDescriptorPanel controller) {
  3. this.controller = controller;
  4. initComponents();
  5. instructions.setEditorKit(new HTMLEditorKit());
  6. instructions.setBackground(instructionPanel.getBackground());
  7. disableHostSensitiveComponents();
  8. refreshRunnable = new RefreshRunnable();
  9. refreshSourceFolderTask = RP2.create(refreshRunnable);
  10. addListeners();
  11. }

代码示例来源:origin: org.gephi/ui-components

  1. public JHTMLEditorPane() {
  2. super();
  3. setEditorKit(new HTMLEditorKit());
  4. setEditable(false);
  5. setOpaque(true);
  6. setAutoscrolls(true);
  7. addHyperlinkListener(this);
  8. setTransferHandler(new HTMLTextAreaTransferHandler());
  9. setFont(UIManager.getFont("Label.font")); //NOI18N
  10. addMouseListener(this);
  11. }

代码示例来源:origin: com.google.code.findbugs/findbugs

  1. private void setStyleSheets() {
  2. StyleSheet styleSheet = new StyleSheet();
  3. styleSheet.addRule("body {font-size: " + Driver.getFontSize() + "pt}");
  4. styleSheet.addRule("H1 {color: red; font-size: 120%; font-weight: bold;}");
  5. styleSheet.addRule("code {font-family: courier; font-size: " + Driver.getFontSize() + "pt}");
  6. styleSheet.addRule(" a:link { color: #0000FF; } ");
  7. styleSheet.addRule(" a:visited { color: #800080; } ");
  8. styleSheet.addRule(" a:active { color: #FF0000; text-decoration: underline; } ");
  9. HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
  10. htmlEditorKit.setStyleSheet(styleSheet);
  11. mainFrame.summaryHtmlArea.setEditorKit(htmlEditorKit);
  12. }

相关文章