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

x33g5p2x  于2022-01-20 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(146)

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

HTMLEditorKit.setStyleSheet介绍

暂无

代码示例

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

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

代码示例来源: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. StyleSheet ss = new StyleSheet();
  2. ss.importStyleSheet(styleSheetURL);
  3. HTMLEditorKit kit = (HTMLEditorKit)jEditorPane.getEditorKit();
  4. kit.setStyleSheet(ss);

代码示例来源: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: 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. URL resource = getClass().getResource("/stylesheet.css");
  2. styleSheet.importStyleSheet(resource);
  3. htmlEditorKit.setStyleSheet(styleSheet);

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

  1. protected EditorKit createDefaultEditorKit() {
  2. // it is extremelly slow to init it
  3. // new RuntimeException("new HTMLEditorKit").printStackTrace();
  4. if (htmlKit == null){
  5. htmlKit= new HTMLEditorKit ();
  6. setEditorKit(htmlKit);
  7. // override the Swing default CSS to make the HTMLEditorKit use the
  8. // same font as the rest of the UI.
  9. // XXX the style sheet is shared by all HTMLEditorKits. We must
  10. // detect if it has been tweaked by ourselves or someone else
  11. // (template description for example) and avoid doing the same
  12. // thing again
  13. if (htmlKit.getStyleSheet().getStyleSheets() != null)
  14. return htmlKit;
  15. javax.swing.text.html.StyleSheet css = new javax.swing.text.html.StyleSheet();
  16. java.awt.Font f = /*new javax.swing.JTextArea().*/ getFont();
  17. css.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  18. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  19. css.addStyleSheet(htmlKit.getStyleSheet());
  20. htmlKit.setStyleSheet(css);
  21. }
  22. return htmlKit;
  23. }
  24. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

  1. protected EditorKit createDefaultEditorKit() {
  2. // it is extremelly slow to init it
  3. if (htmlKit == null){
  4. htmlKit= new HTMLEditorKit ();
  5. setEditorKit(htmlKit);
  6. // override the Swing default CSS to make the HTMLEditorKit use the
  7. // same font as the rest of the UI.
  8. // XXX the style sheet is shared by all HTMLEditorKits. We must
  9. // detect if it has been tweaked by ourselves or someone else
  10. // (template description for example) and avoid doing the same
  11. // thing again
  12. if (htmlKit.getStyleSheet().getStyleSheets() != null)
  13. return htmlKit;
  14. javax.swing.text.html.StyleSheet css = new javax.swing.text.html.StyleSheet();
  15. java.awt.Font f = getFont();
  16. css.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  17. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  18. css.addStyleSheet(htmlKit.getStyleSheet());
  19. htmlKit.setStyleSheet(css);
  20. }
  21. return htmlKit;
  22. }
  23. }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-deprecated-pre61completion

  1. protected EditorKit createDefaultEditorKit() {
  2. // it is extremelly slow to init it
  3. // new RuntimeException("new HTMLEditorKit").printStackTrace();
  4. if (htmlKit == null){
  5. htmlKit= new HTMLEditorKit ();
  6. setEditorKit(htmlKit);
  7. // override the Swing default CSS to make the HTMLEditorKit use the
  8. // same font as the rest of the UI.
  9. // XXX the style sheet is shared by all HTMLEditorKits. We must
  10. // detect if it has been tweaked by ourselves or someone else
  11. // (template description for example) and avoid doing the same
  12. // thing again
  13. if (htmlKit.getStyleSheet().getStyleSheets() != null)
  14. return htmlKit;
  15. javax.swing.text.html.StyleSheet css = new javax.swing.text.html.StyleSheet();
  16. java.awt.Font f = /*new javax.swing.JTextArea().*/ getFont();
  17. css.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
  18. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  19. css.addStyleSheet(htmlKit.getStyleSheet());
  20. htmlKit.setStyleSheet(css);
  21. }
  22. return htmlKit;
  23. }
  24. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders

  1. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  2. css.addStyleSheet(htmlkit.getStyleSheet());
  3. htmlkit.setStyleSheet(css);

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

  1. .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
  2. css.addStyleSheet(htmlKit.getStyleSheet());
  3. htmlKit.setStyleSheet(css);

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

  1. messageEditorPaneHTMLEditorKit.setStyleSheet(styleSheet);
  2. HTMLDocument document = (HTMLDocument) messageEditorPaneHTMLEditorKit.createDefaultDocument();

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

  1. this.kit.setStyleSheet(styleSheet);

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

  1. htmlEditorKit.setStyleSheet(styleSheet);
  2. htmlDocument = (HTMLDocument) htmlEditorKit.createDefaultDocument();
  3. jTextPane = new JTextPane();

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

相关文章