⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debughtmleditorkit.java

📁 java swing 开发代码
💻 JAVA
字号:
// DebugHTMLEditorKit.java// A simple extension of the HTMLEditor kit that uses a verbose ViewFactory.//package	jswing.ch23;import javax.swing.*;import javax.swing.text.*;import javax.swing.text.html.*;public class DebugHTMLEditorKit extends HTMLEditorKit {  public static HTML.Tag ORA = new HTML.UnknownTag("ora");  public static AttributeSet currentAnchor;  public void install(JEditorPane paneEditor) {    super.install(paneEditor);    StyleSheet ss = getStyleSheet();    java.util.Enumeration e = ss.getStyleNames();    while (e.hasMoreElements()) {      System.out.println(e.nextElement());    }  }  public ViewFactory getViewFactory() {    return new VerboseViewFactory();  }  public static class VerboseViewFactory extends HTMLEditorKit.HTMLFactory  {    public View create(Element elem) {      System.out.print("Element: " + elem.getName());      Object o=elem.getAttributes().        getAttribute(StyleConstants.NameAttribute);      HTML.Tag kind = (HTML.Tag) o;      System.out.println(" view as: " + o);      dumpElementAttributes(elem);      return super.create(elem);    }    private void dumpElementAttributes(Element elem) {      AttributeSet attrs = elem.getAttributes();      java.util.Enumeration names = attrs.getAttributeNames();      while (names.hasMoreElements()) {        Object key = names.nextElement();        System.out.println("  " + key + " : " + attrs.getAttribute(key));      }      try {        System.out.println("  " +           elem.getDocument().getText(elem.getStartOffset(),             elem.getEndOffset()));      } catch (Exception e) { // We don't deal with null elements for now.      }    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -