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

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

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

StyleSheet.loadRules介绍

暂无

代码示例

代码示例来源: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: org.swinglabs.swingx/swingx-core

  1. /**
  2. * Sets the font used for HTML displays to the specified font. Components
  3. * that display HTML do not necessarily honor font properties, since the
  4. * HTML document can override these values. Calling {@code setHtmlFont}
  5. * after the data is set will force the HTML display to use the font
  6. * specified to this method.
  7. *
  8. * @param doc
  9. * the HTML document to update
  10. * @param font
  11. * the font to use
  12. * @throws NullPointerException
  13. * if any parameter is {@code null}
  14. */
  15. public static void setHtmlFont(HTMLDocument doc, Font font) {
  16. String stylesheet = String.format(STYLESHEET, font.getName(),
  17. font.getSize(), font.getName(), font.getSize());
  18. try {
  19. doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
  20. } catch (IOException e) {
  21. //this should never happen with our sheet
  22. throw new IllegalStateException(e);
  23. }
  24. }

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

  1. /**
  2. * Sets the font used for HTML displays to the specified font. Components
  3. * that display HTML do not necessarily honor font properties, since the
  4. * HTML document can override these values. Calling {@code setHtmlFont}
  5. * after the data is set will force the HTML display to use the font
  6. * specified to this method.
  7. *
  8. * @param doc
  9. * the HTML document to update
  10. * @param font
  11. * the font to use
  12. * @throws NullPointerException
  13. * if any parameter is {@code null}
  14. */
  15. public static void setHtmlFont(HTMLDocument doc, Font font) {
  16. String stylesheet = String.format(STYLESHEET, font.getName(),
  17. font.getSize(), font.getName(), font.getSize());
  18. try {
  19. doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
  20. } catch (IOException e) {
  21. //this should never happen with our sheet
  22. throw new IllegalStateException(e);
  23. }
  24. }

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

  1. /**
  2. * Sets the font used for HTML displays to the specified font. Components
  3. * that display HTML do not necessarily honor font properties, since the
  4. * HTML document can override these values. Calling {@code setHtmlFont}
  5. * after the data is set will force the HTML display to use the font
  6. * specified to this method.
  7. *
  8. * @param doc
  9. * the HTML document to update
  10. * @param font
  11. * the font to use
  12. * @throws NullPointerException
  13. * if any parameter is {@code null}
  14. */
  15. public static void setHtmlFont(HTMLDocument doc, Font font) {
  16. String stylesheet = String.format(STYLESHEET, font.getName(),
  17. font.getSize(), font.getName(), font.getSize());
  18. try {
  19. doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
  20. } catch (IOException e) {
  21. //this should never happen with our sheet
  22. throw new IllegalStateException(e);
  23. }
  24. }

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

  1. /**
  2. * Sets the font used for HTML displays to the specified font. Components
  3. * that display HTML do not necessarily honor font properties, since the
  4. * HTML document can override these values. Calling {@code setHtmlFont}
  5. * after the data is set will force the HTML display to use the font
  6. * specified to this method.
  7. *
  8. * @param doc
  9. * the HTML document to update
  10. * @param font
  11. * the font to use
  12. * @throws NullPointerException
  13. * if any parameter is {@code null}
  14. */
  15. public static void setHtmlFont(HTMLDocument doc, Font font) {
  16. String stylesheet = String.format(STYLESHEET, font.getName(),
  17. font.getSize(), font.getName(), font.getSize());
  18. try {
  19. doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
  20. } catch (IOException e) {
  21. //this should never happen with our sheet
  22. throw new IllegalStateException(e);
  23. }
  24. }

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

  1. /**
  2. * Sets the font used for HTML displays to the specified font. Components
  3. * that display HTML do not necessarily honor font properties, since the
  4. * HTML document can override these values. Calling {@code setHtmlFont}
  5. * after the data is set will force the HTML display to use the font
  6. * specified to this method.
  7. *
  8. * @param doc
  9. * the HTML document to update
  10. * @param font
  11. * the font to use
  12. * @throws NullPointerException
  13. * if any parameter is {@code null}
  14. */
  15. public static void setHtmlFont(HTMLDocument doc, Font font) {
  16. String stylesheet = String.format(STYLESHEET, font.getName(),
  17. font.getSize(), font.getName(), font.getSize());
  18. try {
  19. doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
  20. } catch (IOException e) {
  21. //this should never happen with our sheet
  22. throw new IllegalStateException(e);
  23. }
  24. }

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

  1. sheet.loadRules(reader, null);
  2. reader.close();
  3. sheet.loadRules(reader, null);
  4. reader.close();

代码示例来源: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-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: 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: org.codehaus.jtstand/jtstand-desktop

  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: RPTools/maptool

  1. HTMLDocument document = (HTMLDocument) getDocument();
  2. StyleSheet style = document.getStyleSheet();
  3. style.loadRules(new StringReader(cssText), null);
  4. } catch (ParserException e) {

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

  1. /**
  2. * Method for loading a Stylesheet into the app
  3. */
  4. private void openStyleSheet(File fileCSS) throws IOException {
  5. if (fileCSS == null) {
  6. fileCSS = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsCSS, Translatrix
  7. .getTranslationString("FiletypeCSS"));
  8. }
  9. if (fileCSS != null) {
  10. String currDocText = jtpMain.getText();
  11. htmlDoc = (ExtendedHTMLDocument) (htmlKit.createDefaultDocument());
  12. styleSheet = htmlDoc.getStyleSheet();
  13. URL cssUrl = fileCSS.toURL();
  14. InputStream is = cssUrl.openStream();
  15. BufferedReader br = new BufferedReader(new InputStreamReader(is));
  16. styleSheet.loadRules(br, cssUrl);
  17. br.close();
  18. htmlDoc = new ExtendedHTMLDocument(styleSheet);
  19. registerDocument(htmlDoc);
  20. jtpMain.setText(currDocText);
  21. jtpSource.setText(jtpMain.getText());
  22. }
  23. refreshOnUpdate();
  24. }

代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared

  1. doc.getStyleSheet().loadRules(
  2. new java.io.StringReader(stylesheet),
  3. null);

代码示例来源:origin: com.github.arnabk/pgslookandfeel

  1. doc.getStyleSheet().loadRules(
  2. new java.io.StringReader(stylesheet),
  3. null);

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

  1. styleSheet = htmlDoc.getStyleSheet();
  2. BufferedReader br = new BufferedReader(new InputStreamReader(urlStyleSheet.openStream()));
  3. styleSheet.loadRules(br, urlStyleSheet);
  4. br.close();
  5. htmlDoc = new ExtendedHTMLDocument(styleSheet);

相关文章