javax.swing.text.html.StyleSheet.addStyleSheet()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(199)

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

StyleSheet.addStyleSheet介绍

暂无

代码示例

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

css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
      .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  css2.addStyleSheet(css);
  htmlkit.setStyleSheet(css2);
} catch( RuntimeException ex ) {

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

@Override
  public Document createDefaultDocument() {
    StyleSheet styles = getStyleSheet();
    //#200472 - hack to make JDK 1.7 javadoc readable
    StyleSheet ss = new FilteredStyleSheet();
    ss.addStyleSheet(styles);
    HTMLDocument doc = new HTMLDocument(ss);
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(4);
    doc.setTokenThreshold(100);
    return doc;
  }
};

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform

private void postInitComponents() {
  final HTMLEditorKit htmlkit = new HTMLEditorKit();
  final StyleSheet css = htmlkit.getStyleSheet();
  if (css.getStyleSheets() == null) {
    final StyleSheet css2 = new StyleSheet();
    final Font f = new JLabel().getFont();
    css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
    .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
    css2.addStyleSheet(css);
    htmlkit.setStyleSheet(css2);
  }
  jTextPane1.setEditorKit(htmlkit);
  jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class, "MSG_BrokenProject")); // NOI18N
}

代码示例来源:origin: dcaoyuan/nbscala

private void postInitComponents () {
  this.platformName.setText (platform.getDisplayName());
  Collection installFolders = platform.getInstallFolderURLs();
  if (installFolders.size() > 0) {
    this.platformHome.setForeground(new Color (164,0,0));
    this.platformHome.setText (new File(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
  }
  HTMLEditorKit htmlkit = new HTMLEditorKit();                
  StyleSheet css = htmlkit.getStyleSheet();
  if (css.getStyleSheets() == null) {
    StyleSheet css2 = new StyleSheet();
    Font f = jLabel1.getFont();
    css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
      .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
    css2.addStyleSheet(css);
    htmlkit.setStyleSheet(css2);
  }
  jTextPane1.setEditorKit(htmlkit);        
  jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
}

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

class CustomEditorKit extends HTMLEditorKit {
  @Override
  public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
    HTMLWriterHack writer = new HTMLWriterHack(out, (HTMLDocumentHack) doc);
    writer.write();
  }
  @Override
  public Document createDefaultDocument() {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new StyleSheet();
    ss.addStyleSheet(styles);
    HTMLDocumentHack doc = new HTMLDocumentHack(ss);
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(4);
    doc.setTokenThreshold(100);
    return doc;
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-platform

private void postInitComponents () {
  this.platformName.setText (platform.getDisplayName());
  Collection installFolders = platform.getInstallFolderURLs();
  if (installFolders.size() > 0) {
    this.platformHome.setForeground(new Color (164,0,0));
    this.platformHome.setText (new File(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
  }
  HTMLEditorKit htmlkit = new HTMLEditorKit();                
  StyleSheet css = htmlkit.getStyleSheet();
  if (css.getStyleSheets() == null) {
    StyleSheet css2 = new StyleSheet();
    Font f = jLabel1.getFont();
    css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
      .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
    css2.addStyleSheet(css);
    htmlkit.setStyleSheet(css2);
  }
  jTextPane1.setEditorKit(htmlkit);        
  jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
}

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

/**
 * Overriden to return our own slimmed down style sheet.
 */
public StyleSheet getStyleSheet() {
  if (defaultStyles == null) {
    defaultStyles = new StyleSheet();
    StringReader r = new StringReader(ScaledHTML.styleChanges);
    try {
      defaultStyles.loadRules(r, null);
    }
    catch (Throwable e) {
      // don't want to die in static initialization... 
      // just display things wrong.
    }
    r.close();
    defaultStyles.addStyleSheet(super.getStyleSheet());
  }
  return defaultStyles;
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
   * Overriden to return our own slimmed down style sheet.
   */
  @Override
  public StyleSheet getStyleSheet() {
    if (defaultStyles == null) {
    defaultStyles = new StyleSheet();
    StringReader r = new StringReader(styleChanges);
    try {
      defaultStyles.loadRules(r, null);
    } catch (Throwable e) {
      // don't want to die in static initialization... 
      // just display things wrong.
    }
    r.close();
    defaultStyles.addStyleSheet(super.getStyleSheet());
  }
  return defaultStyles;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
   * Overriden to return our own slimmed down style sheet.
   */
  @Override
  public StyleSheet getStyleSheet() {
    if (defaultStyles == null) {
    defaultStyles = new StyleSheet();
    StringReader r = new StringReader(styleChanges);
    try {
      defaultStyles.loadRules(r, null);
    } catch (Throwable e) {
      // don't want to die in static initialization... 
      // just display things wrong.
    }
    r.close();
    defaultStyles.addStyleSheet(super.getStyleSheet());
  }
  return defaultStyles;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
   * Overriden to return our own slimmed down style sheet.
   */
  @Override
  public StyleSheet getStyleSheet() {
    if (defaultStyles == null) {
    defaultStyles = new StyleSheet();
    StringReader r = new StringReader(styleChanges);
    try {
      defaultStyles.loadRules(r, null);
    } catch (Throwable e) {
      // don't want to die in static initialization... 
      // just display things wrong.
    }
    r.close();
    defaultStyles.addStyleSheet(super.getStyleSheet());
  }
  return defaultStyles;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
   * Overriden to return our own slimmed down style sheet.
   */
  @Override
  public StyleSheet getStyleSheet() {
    if (defaultStyles == null) {
    defaultStyles = new StyleSheet();
    StringReader r = new StringReader(styleChanges);
    try {
      defaultStyles.loadRules(r, null);
    } catch (Throwable e) {
      // don't want to die in static initialization... 
      // just display things wrong.
    }
    r.close();
    defaultStyles.addStyleSheet(super.getStyleSheet());
  }
  return defaultStyles;
}

代码示例来源:origin: JetBrains/jediterm

public static HTMLEditorKit getHTMLEditorKit(boolean noGapsBetweenParagraphs) {
  Font font = getLabelFont();
  @NonNls String family = !SystemInfo.isWindows && font != null ? font.getFamily() : "Tahoma";
  int size = font != null ? font.getSize() : JBUI.scale(11);
  String customCss = String.format("body, div, p { font-family: %s; font-size: %s; }", family, size);
  if (noGapsBetweenParagraphs) {
    customCss += " p { margin-top: 0; }";
  }
  final StyleSheet style = new StyleSheet();
  style.addStyleSheet(isUnderDarcula() ? (StyleSheet) UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
  style.addRule(customCss);
  return new HTMLEditorKit() {
    @Override
    public StyleSheet getStyleSheet() {
      return style;
    }
  };
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                     Color foreground) {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  doc.setPreservesUnknownTags(false);
  return doc;
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                     Color foreground) {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  doc.setPreservesUnknownTags(false);
  return doc;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                     Color foreground) {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  doc.setPreservesUnknownTags(false);
  return doc;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                     Color foreground) {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  doc.setPreservesUnknownTags(false);
  return doc;
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                     Color foreground) {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  doc.setPreservesUnknownTags(false);
  return doc;
}

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

public Document createDefaultDocument(JLabel c) {
    Font font = c.getFont();
    Color foreground = c.getForeground();
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new ScaledStyleSheet();
    ss.addStyleSheet(styles);
    HTMLDocument doc = new HTMLDocument(ss);
    doc.setPreservesUnknownTags(false);
    doc.getStyleSheet().addRule(new StringBuffer("body {").append(new CssRuleBuilder()
    .withCSSFont(font, UITools.FONT_SCALE_FACTOR)
    .withColor(foreground)
    .withAlignment(c.getHorizontalAlignment())).append("}").toString());
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
    doc.setPreservesUnknownTags(false);
    return doc;
  }
}

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

@Override
public Document createDefaultDocument() {
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new ScaledStyleSheet();
  ss.addStyleSheet(styles);
  HTMLDocument doc = new HTMLDocument(ss);
  doc.setParser(getParser());
  doc.setAsynchronousLoadPriority(4);
  doc.setTokenThreshold(100);
  return doc;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

public Document createDefaultDocument()
{
  StyleSheet styles = getStyleSheet();
  StyleSheet ss = new StyleSheet();
  ss.addStyleSheet(styles);
  ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
  doc.setParser(getParser());
  doc.setAsynchronousLoadPriority(4);
  doc.setTokenThreshold(100);
  return doc;
}

相关文章