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

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

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

StyleSheet.<init>介绍

暂无

代码示例

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

StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();

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

import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;

HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);

URL url = new URL(location of your stylesheet);
StyleSheet styleSheet = new StyleSheet();
styleSheet.importStyleSheet(url)
kit.setStyleSheet(styleSheet);

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

import javax.swing.text.html.StyleSheet;
StyleSheet s = new StyleSheet();
String rgb="black";
Color c1 = s.stringToColor(rgb);
r1=c1.getRed();
g1=c1.getGreen();
b1=c1.getBlue();
System.out.println(r1+" "+g1+" "+b1);

代码示例来源:origin: Slowpoke101/FTBLaunch

public static StyleSheet makeStyleSheet (String name) {
  try {
    StyleSheet sheet = new StyleSheet();
    Reader reader = new InputStreamReader(System.class.getResourceAsStream("/css/" + name + ".css"));
    sheet.loadRules(reader, null);
    reader.close();
    return sheet;
  } catch (Exception ex) {
    ex.printStackTrace();
    return null;
  }
}

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

import javax.swing.text.html.*;

StyleSheet styleSheet = new StyleSheet()
AttributeSet dec = ss.getDeclaration("margin:2px;padding:3px");
Object marginLeft = dec.getAttribute(CSS.Attribute.MARGIN_LEFT);
String marginLeftString = marginLeft.toString(); // "2px"

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

StyleSheet styles = new StyleSheet();
styles.loadStyle("h1", "color", "#008080");

//parsing
List<Element> parsedTags = HTMLWorker.parseToList(new StringReader(htmlSnippet), styles); 
for (Element tag : parsedTags)
{       
 page.addElement(tag);
 page.go();
}

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

StyleSheet ss = new StyleSheet();
ss.importStyleSheet(styleSheetURL);
HTMLEditorKit kit = (HTMLEditorKit)jEditorPane.getEditorKit();
kit.setStyleSheet(ss);

代码示例来源: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: 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: 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: 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: stackoverflow.com

StyleSheet css = new StyleSheet();
 css.LoadTagStyle("body", "face", "Garamond");
 css.LoadTagStyle("body", "encoding", "Identity-H");
 css.LoadTagStyle("body", "size", "12pt");

代码示例来源: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: 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: 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: 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;
}

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

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

相关文章