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

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

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

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

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

  1. import javax.swing.text.html.HTMLEditorKit;
  2. import javax.swing.text.html.StyleSheet;
  3. HTMLEditorKit kit = new HTMLEditorKit();
  4. jEditorPane.setEditorKit(kit);
  5. URL url = new URL(location of your stylesheet);
  6. StyleSheet styleSheet = new StyleSheet();
  7. styleSheet.importStyleSheet(url)
  8. kit.setStyleSheet(styleSheet);

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

  1. import javax.swing.text.html.StyleSheet;
  2. StyleSheet s = new StyleSheet();
  3. String rgb="black";
  4. Color c1 = s.stringToColor(rgb);
  5. r1=c1.getRed();
  6. g1=c1.getGreen();
  7. b1=c1.getBlue();
  8. System.out.println(r1+" "+g1+" "+b1);

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

  1. public static StyleSheet makeStyleSheet (String name) {
  2. try {
  3. StyleSheet sheet = new StyleSheet();
  4. Reader reader = new InputStreamReader(System.class.getResourceAsStream("/css/" + name + ".css"));
  5. sheet.loadRules(reader, null);
  6. reader.close();
  7. return sheet;
  8. } catch (Exception ex) {
  9. ex.printStackTrace();
  10. return null;
  11. }
  12. }

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

  1. import javax.swing.text.html.*;
  2. StyleSheet styleSheet = new StyleSheet()
  3. AttributeSet dec = ss.getDeclaration("margin:2px;padding:3px");
  4. Object marginLeft = dec.getAttribute(CSS.Attribute.MARGIN_LEFT);
  5. String marginLeftString = marginLeft.toString(); // "2px"

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

  1. StyleSheet styles = new StyleSheet();
  2. styles.loadStyle("h1", "color", "#008080");
  3. //parsing
  4. List<Element> parsedTags = HTMLWorker.parseToList(new StringReader(htmlSnippet), styles);
  5. for (Element tag : parsedTags)
  6. {
  7. page.addElement(tag);
  8. page.go();
  9. }

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

  1. StyleSheet ss = new StyleSheet();
  2. ss.importStyleSheet(styleSheetURL);
  3. HTMLEditorKit kit = (HTMLEditorKit)jEditorPane.getEditorKit();
  4. kit.setStyleSheet(ss);

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

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

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

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

相关文章