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

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

本文整理了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

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

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

  1. @Override
  2. public Document createDefaultDocument() {
  3. StyleSheet styles = getStyleSheet();
  4. //#200472 - hack to make JDK 1.7 javadoc readable
  5. StyleSheet ss = new FilteredStyleSheet();
  6. ss.addStyleSheet(styles);
  7. HTMLDocument doc = new HTMLDocument(ss);
  8. doc.setParser(getParser());
  9. doc.setAsynchronousLoadPriority(4);
  10. doc.setTokenThreshold(100);
  11. return doc;
  12. }
  13. };

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

  1. private void postInitComponents() {
  2. final HTMLEditorKit htmlkit = new HTMLEditorKit();
  3. final StyleSheet css = htmlkit.getStyleSheet();
  4. if (css.getStyleSheets() == null) {
  5. final StyleSheet css2 = new StyleSheet();
  6. final Font f = new JLabel().getFont();
  7. css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  8. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  9. css2.addStyleSheet(css);
  10. htmlkit.setStyleSheet(css2);
  11. }
  12. jTextPane1.setEditorKit(htmlkit);
  13. jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class, "MSG_BrokenProject")); // NOI18N
  14. }

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

  1. private void postInitComponents () {
  2. this.platformName.setText (platform.getDisplayName());
  3. Collection installFolders = platform.getInstallFolderURLs();
  4. if (installFolders.size() > 0) {
  5. this.platformHome.setForeground(new Color (164,0,0));
  6. this.platformHome.setText (new File(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
  7. }
  8. HTMLEditorKit htmlkit = new HTMLEditorKit();
  9. StyleSheet css = htmlkit.getStyleSheet();
  10. if (css.getStyleSheets() == null) {
  11. StyleSheet css2 = new StyleSheet();
  12. Font f = jLabel1.getFont();
  13. css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  14. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  15. css2.addStyleSheet(css);
  16. htmlkit.setStyleSheet(css2);
  17. }
  18. jTextPane1.setEditorKit(htmlkit);
  19. jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
  20. }

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

  1. class CustomEditorKit extends HTMLEditorKit {
  2. @Override
  3. public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
  4. HTMLWriterHack writer = new HTMLWriterHack(out, (HTMLDocumentHack) doc);
  5. writer.write();
  6. }
  7. @Override
  8. public Document createDefaultDocument() {
  9. StyleSheet styles = getStyleSheet();
  10. StyleSheet ss = new StyleSheet();
  11. ss.addStyleSheet(styles);
  12. HTMLDocumentHack doc = new HTMLDocumentHack(ss);
  13. doc.setParser(getParser());
  14. doc.setAsynchronousLoadPriority(4);
  15. doc.setTokenThreshold(100);
  16. return doc;
  17. }
  18. }

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

  1. private void postInitComponents () {
  2. this.platformName.setText (platform.getDisplayName());
  3. Collection installFolders = platform.getInstallFolderURLs();
  4. if (installFolders.size() > 0) {
  5. this.platformHome.setForeground(new Color (164,0,0));
  6. this.platformHome.setText (new File(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
  7. }
  8. HTMLEditorKit htmlkit = new HTMLEditorKit();
  9. StyleSheet css = htmlkit.getStyleSheet();
  10. if (css.getStyleSheets() == null) {
  11. StyleSheet css2 = new StyleSheet();
  12. Font f = jLabel1.getFont();
  13. css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  14. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  15. css2.addStyleSheet(css);
  16. htmlkit.setStyleSheet(css2);
  17. }
  18. jTextPane1.setEditorKit(htmlkit);
  19. jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
  20. }

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

  1. /**
  2. * Overriden to return our own slimmed down style sheet.
  3. */
  4. public StyleSheet getStyleSheet() {
  5. if (defaultStyles == null) {
  6. defaultStyles = new StyleSheet();
  7. StringReader r = new StringReader(ScaledHTML.styleChanges);
  8. try {
  9. defaultStyles.loadRules(r, null);
  10. }
  11. catch (Throwable e) {
  12. // don't want to die in static initialization...
  13. // just display things wrong.
  14. }
  15. r.close();
  16. defaultStyles.addStyleSheet(super.getStyleSheet());
  17. }
  18. return defaultStyles;
  19. }

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

  1. /**
  2. * Overriden to return our own slimmed down style sheet.
  3. */
  4. @Override
  5. public StyleSheet getStyleSheet() {
  6. if (defaultStyles == null) {
  7. defaultStyles = new StyleSheet();
  8. StringReader r = new StringReader(styleChanges);
  9. try {
  10. defaultStyles.loadRules(r, null);
  11. } catch (Throwable e) {
  12. // don't want to die in static initialization...
  13. // just display things wrong.
  14. }
  15. r.close();
  16. defaultStyles.addStyleSheet(super.getStyleSheet());
  17. }
  18. return defaultStyles;
  19. }

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

  1. /**
  2. * Overriden to return our own slimmed down style sheet.
  3. */
  4. @Override
  5. public StyleSheet getStyleSheet() {
  6. if (defaultStyles == null) {
  7. defaultStyles = new StyleSheet();
  8. StringReader r = new StringReader(styleChanges);
  9. try {
  10. defaultStyles.loadRules(r, null);
  11. } catch (Throwable e) {
  12. // don't want to die in static initialization...
  13. // just display things wrong.
  14. }
  15. r.close();
  16. defaultStyles.addStyleSheet(super.getStyleSheet());
  17. }
  18. return defaultStyles;
  19. }

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

  1. /**
  2. * Overriden to return our own slimmed down style sheet.
  3. */
  4. @Override
  5. public StyleSheet getStyleSheet() {
  6. if (defaultStyles == null) {
  7. defaultStyles = new StyleSheet();
  8. StringReader r = new StringReader(styleChanges);
  9. try {
  10. defaultStyles.loadRules(r, null);
  11. } catch (Throwable e) {
  12. // don't want to die in static initialization...
  13. // just display things wrong.
  14. }
  15. r.close();
  16. defaultStyles.addStyleSheet(super.getStyleSheet());
  17. }
  18. return defaultStyles;
  19. }

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

  1. /**
  2. * Overriden to return our own slimmed down style sheet.
  3. */
  4. @Override
  5. public StyleSheet getStyleSheet() {
  6. if (defaultStyles == null) {
  7. defaultStyles = new StyleSheet();
  8. StringReader r = new StringReader(styleChanges);
  9. try {
  10. defaultStyles.loadRules(r, null);
  11. } catch (Throwable e) {
  12. // don't want to die in static initialization...
  13. // just display things wrong.
  14. }
  15. r.close();
  16. defaultStyles.addStyleSheet(super.getStyleSheet());
  17. }
  18. return defaultStyles;
  19. }

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

  1. public static HTMLEditorKit getHTMLEditorKit(boolean noGapsBetweenParagraphs) {
  2. Font font = getLabelFont();
  3. @NonNls String family = !SystemInfo.isWindows && font != null ? font.getFamily() : "Tahoma";
  4. int size = font != null ? font.getSize() : JBUI.scale(11);
  5. String customCss = String.format("body, div, p { font-family: %s; font-size: %s; }", family, size);
  6. if (noGapsBetweenParagraphs) {
  7. customCss += " p { margin-top: 0; }";
  8. }
  9. final StyleSheet style = new StyleSheet();
  10. style.addStyleSheet(isUnderDarcula() ? (StyleSheet) UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
  11. style.addRule(customCss);
  12. return new HTMLEditorKit() {
  13. @Override
  14. public StyleSheet getStyleSheet() {
  15. return style;
  16. }
  17. };
  18. }

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

  1. /**
  2. * Sets the async policy to flush everything in one chunk, and
  3. * to not display unknown tags.
  4. */
  5. public Document createDefaultDocument(Font defaultFont,
  6. Color foreground) {
  7. StyleSheet styles = getStyleSheet();
  8. StyleSheet ss = new StyleSheet();
  9. ss.addStyleSheet(styles);
  10. BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  11. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  12. doc.setPreservesUnknownTags(false);
  13. return doc;
  14. }

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

  1. /**
  2. * Sets the async policy to flush everything in one chunk, and
  3. * to not display unknown tags.
  4. */
  5. public Document createDefaultDocument(Font defaultFont,
  6. Color foreground) {
  7. StyleSheet styles = getStyleSheet();
  8. StyleSheet ss = new StyleSheet();
  9. ss.addStyleSheet(styles);
  10. BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  11. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  12. doc.setPreservesUnknownTags(false);
  13. return doc;
  14. }

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

  1. /**
  2. * Sets the async policy to flush everything in one chunk, and
  3. * to not display unknown tags.
  4. */
  5. public Document createDefaultDocument(Font defaultFont,
  6. Color foreground) {
  7. StyleSheet styles = getStyleSheet();
  8. StyleSheet ss = new StyleSheet();
  9. ss.addStyleSheet(styles);
  10. BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  11. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  12. doc.setPreservesUnknownTags(false);
  13. return doc;
  14. }

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

  1. /**
  2. * Sets the async policy to flush everything in one chunk, and
  3. * to not display unknown tags.
  4. */
  5. public Document createDefaultDocument(Font defaultFont,
  6. Color foreground) {
  7. StyleSheet styles = getStyleSheet();
  8. StyleSheet ss = new StyleSheet();
  9. ss.addStyleSheet(styles);
  10. BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  11. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  12. doc.setPreservesUnknownTags(false);
  13. return doc;
  14. }

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

  1. /**
  2. * Sets the async policy to flush everything in one chunk, and
  3. * to not display unknown tags.
  4. */
  5. public Document createDefaultDocument(Font defaultFont,
  6. Color foreground) {
  7. StyleSheet styles = getStyleSheet();
  8. StyleSheet ss = new StyleSheet();
  9. ss.addStyleSheet(styles);
  10. BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
  11. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  12. doc.setPreservesUnknownTags(false);
  13. return doc;
  14. }

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

  1. public Document createDefaultDocument(JLabel c) {
  2. Font font = c.getFont();
  3. Color foreground = c.getForeground();
  4. StyleSheet styles = getStyleSheet();
  5. StyleSheet ss = new ScaledStyleSheet();
  6. ss.addStyleSheet(styles);
  7. HTMLDocument doc = new HTMLDocument(ss);
  8. doc.setPreservesUnknownTags(false);
  9. doc.getStyleSheet().addRule(new StringBuffer("body {").append(new CssRuleBuilder()
  10. .withCSSFont(font, UITools.FONT_SCALE_FACTOR)
  11. .withColor(foreground)
  12. .withAlignment(c.getHorizontalAlignment())).append("}").toString());
  13. doc.setParser(getParser());
  14. doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
  15. doc.setPreservesUnknownTags(false);
  16. return doc;
  17. }
  18. }

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

  1. @Override
  2. public Document createDefaultDocument() {
  3. StyleSheet styles = getStyleSheet();
  4. StyleSheet ss = new ScaledStyleSheet();
  5. ss.addStyleSheet(styles);
  6. HTMLDocument doc = new HTMLDocument(ss);
  7. doc.setParser(getParser());
  8. doc.setAsynchronousLoadPriority(4);
  9. doc.setTokenThreshold(100);
  10. return doc;
  11. }

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

  1. public Document createDefaultDocument()
  2. {
  3. StyleSheet styles = getStyleSheet();
  4. StyleSheet ss = new StyleSheet();
  5. ss.addStyleSheet(styles);
  6. ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
  7. doc.setParser(getParser());
  8. doc.setAsynchronousLoadPriority(4);
  9. doc.setTokenThreshold(100);
  10. return doc;
  11. }

相关文章