/** * Outputs the styles as a single element. Styles are not stored as * elements, but part of the document. For the time being styles are * written out as a comment, inside a style tag. */ void writeStyles(StyleSheet sheet) throws IOException { if (sheet != null) { Enumeration styles = sheet.getStyleNames(); if (styles != null) { boolean outputStyle = false; while (styles.hasMoreElements()) { String name = (String) styles.nextElement(); // Don't write out the default style. if (!StyleContext.DEFAULT_STYLE.equals(name) && writeStyle(name, sheet.getStyle(name), outputStyle)) { outputStyle = true; } } if (outputStyle) { writeStyleEndTag(); } } } }
private void postInitComponents () { this.jLabel2.setVisible(false); this.platformHome.setVisible(false); final Collection installFolders = platform.getInstallFolderURLs(); if (platform.getInstallFolders().isEmpty() && installFolders.size() > 0) { this.jLabel2.setVisible(true); this.platformHome.setVisible(true); this.platformHome.setForeground(new Color (164,0,0)); this.platformHome.setText (Utilities.toFile(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath()); } HTMLEditorKit htmlkit = new HTMLEditorKit(); StyleSheet css = htmlkit.getStyleSheet(); if (css.getStyleSheets() == null) { StyleSheet css2 = new StyleSheet(); Font f = jLabel2.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")); }
/** * This method creates and returns a stylesheet that makes the documentation look as it's * supposed to look. * * @return the stylesheet */ private StyleSheet createStyleSheet(StyleSheet css) { css.addRule("* {font-family: Open Sans; font-size: 10px;}"); css.addRule("p {font-size:10px; font-family: Open Sans; margin-top: 0px; padding-top: 0px;}"); css.addRule("ul li {padding-bottom:1ex; font-family: Open Sans; font-size:10px; list-style-type: circle;}"); css.addRule("h2 {font-size:14px; font-family: Open Sans; margin-bottom: 0px; margin-top: 0px;}"); css.addRule("h4 {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 5px;}"); css.addRule("h5 {color: #3399FF; font-size:11px; font-family: Open Sans;}"); css.addRule("h5 img {margin-right:8px; font-family: Open Sans;}"); css.addRule(".typeIcon {height: 10px; width: 10px;}"); css.addRule("td {vertical-align: top; font-family: Open Sans;}"); css.addRule(".lilIcon {padding: 2px 4px 2px 0px;}"); css.addRule("td {font-size: 10px; font-family: Open Sans;}"); css.addRule(".packageName {color: #777777; font-size:10px; font-family: Open Sans; font-weight: normal;}"); css.addRule(".parameterDetails {color: #777777; font-size:9px; font-family: Open Sans;}"); css.addRule(".tutorialProcessLink {margin-top: 6px; margin-bottom: 5px}"); css.addRule("hr {border: 0;height: 1px;}"); css.addRule("a {color:" + SwingTools.getColorHexValue(Colors.LINKBUTTON_LOCAL) + "}"); return css; }
public ExtendedHTMLEditorKit() { styleSheet = new StyleSheet(); try { InputStream is = HTMLEditorKit.class.getResourceAsStream(DEFAULT_CSS); Reader r = new BufferedReader(new InputStreamReader(is, "ISO-8859-1")); styleSheet.loadRules(r, null); r.close(); } catch (Exception e) { // LogService.getRoot().log(Level.WARNING, "Cannot install stylesheet: "+e, e); LogService.getRoot().log( Level.WARNING, I18N.getMessage(LogService.getRoot().getResourceBundle(), "com.rapidminer.gui.tools.ExtendedHTMLEditorKit.installing_stylesheet_error", e), e); // on error we simply have no styles... the html // will look mighty wrong but still function. } }
/** * Creates the main text representation of this result. * * @param text * @return */ private Component makeMainLabel(String text) { JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text); StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet(); css.addRule("body {font-family:Sans;font-size:11pt}"); css.addRule("h3 {margin:0; padding:0}"); css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}"); css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}"); css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}"); css.addRule("ul li {padding-bottom: 2px}"); css.addRule("li.outPorts {padding-bottom: 0px}"); css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")"); css.addRule("li ul li {padding-bottom:0}"); label.setEditable(false); JScrollPane pane = new JScrollPane(label); pane.setOpaque(false); pane.setBackground(null); pane.setBorder(null); return pane; }
/** * This sets all sizes that should be relative to the font size in the HTML * document. This is to respect the OS font size setting used for example * on high DPI monitors. * * @param styleSheet the <code>StyleSheet</code> to modify */ public void buildStyleSheet(StyleSheet styleSheet) { int baseSize = editorPane.getFont().getSize(); String rule = String.format( "body { font-size: %dpt; padding: %dpx; }", Math.round((double) baseSize * 7 / 6), Math.round((double) baseSize * 5 / 6) ); styleSheet.addRule(rule); rule = String.format("h1 { font-size: %dpx; }", baseSize * 2); styleSheet.addRule(rule); rule = String.format("h2 { font-size: %dpx; }", Math.round(baseSize * 1.5)); styleSheet.addRule(rule); rule = String.format("h3 { font-size: %dpx; }", Math.round(baseSize * 1.17)); styleSheet.addRule(rule); rule = String.format("pre, tt { font-size: %dpt; }", baseSize); styleSheet.addRule(rule); rule = String.format("dd { margin-bottom: %dpx; }", Math.round((double) baseSize * 10 / 6)); styleSheet.addRule(rule); }
/** * Outputs the styles as a single element. Styles are not stored as * elements, but part of the document. For the time being styles are written * out as a comment, inside a style tag. */ void writeStyles(StyleSheet sheet) throws IOException { if (sheet != null) { Enumeration styles = sheet.getStyleNames(); if (styles != null) { boolean outputStyle = false; while (styles.hasMoreElements()) { String name = (String) styles.nextElement(); // Don't write out the default style. if (!StyleContext.DEFAULT_STYLE.equals(name) && writeStyle(name, sheet.getStyle(name), outputStyle)) { outputStyle = true; } } if (outputStyle) { writeStyleEndTag(); } } } }
@NotNull public static JEditorPane createTipBrowser() { JEditorPane browser = new JEditorPane(); browser.setEditable(false); browser.setBackground(UIUtil.getTextFieldBackground()); browser.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { BrowserUtil.browse(e.getURL()); } } } ); URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css"); final StyleSheet styleSheet = UIUtil.loadStyleSheet(resource); HTMLEditorKit kit = new HTMLEditorKit() { @Override public StyleSheet getStyleSheet() { return styleSheet != null ? styleSheet : super.getStyleSheet(); } }; browser.setEditorKit(kit); return browser; }
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; } }; }
/** * This method creates and returns a stylesheet that makes the documentation look as it's * supposed to look. * * @return the stylesheet */ private StyleSheet createStyleSheet(StyleSheet css) { css.addRule("body {font-family: Open Sans; font-size: 10px;}"); css.addRule("p {font-size:10px; font-family: Open Sans; margin-top: 0px; padding-top: 0px;}"); css.addRule("ul li {padding-bottom:1ex; font-family: Open Sans; font-size:10px; list-style-type: circle;}"); css.addRule("h2 {font-size:14px; font-family: Open Sans; margin-bottom: 0px; margin-top: 0px;}"); css.addRule("h4 {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 5px;}"); css.addRule("h5 {color: #3399FF; font-size:11px; font-family: Open Sans;}"); css.addRule("h5 img {margin-right:8px; font-family: Open Sans;}"); css.addRule( ".parametersHeading {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 0px;}"); css.addRule(".parametersTable {cellspacing: 0px; border: 0;}"); css.addRule(".typeIcon {height: 10px; width: 10px;}"); css.addRule("td {vertical-align: top; font-family: Open Sans;}"); css.addRule(".lilIcon {padding: 2px 4px 2px 0px;}"); css.addRule("td {font-size: 10px; font-family: Open Sans;}"); css.addRule(".packageName {color: #777777; font-size:10px; font-family: Open Sans; font-weight: normal;}"); css.addRule(".parameterDetails {color: #777777; font-size:9px; font-family: Open Sans;}"); css.addRule(".parameterDetailsCell{margin-bottom: 4px; padding-bottom: 4px;}"); css.addRule(".tutorialProcessLink {margin-top: 6px; margin-bottom: 5px;}"); css.addRule("hr {border: 0;height: 1px;}"); css.addRule("a {color:" + SwingTools.getColorHexValue(Colors.LINKBUTTON_LOCAL) + "}"); css.addRule("table {align:left;}"); css.addRule(".tags {font-size: 9px; color: #777777;}"); return css; }
/** * Creates the main text representation of this result. * * @param text * @return */ private Component makeMainLabel(String text) { JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text); StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet(); css.addRule("body {font-family:Sans;font-size:11pt}"); css.addRule("h3 {margin:0; padding:0}"); css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}"); css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}"); css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}"); css.addRule("ul li {padding-bottom: 2px}"); css.addRule("li.outPorts {padding-bottom: 0px}"); css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")"); css.addRule("li ul li {padding-bottom:0}"); label.setEditable(false); label.setBackground(Colors.WHITE); JScrollPane pane = new JScrollPane(label); pane.setBackground(Colors.WHITE); pane.setBorder(null); return pane; }
/** * Creates new form ScheduleEditor */ public ScheduleEditor(Schedule s) { schedule = s; initComponents(); if (txtSchedule.getEditorKit() instanceof HTMLEditorKit) { StyleSheet ss = ((HTMLEditorKit) txtSchedule.getEditorKit()).getStyleSheet(); ss.addRule("a { text-decoration:none; }"); ss.addRule("body { font-family:Tahoma; font-size:12pt; }"); ss.addRule(".column_name { color:#222222; font-weight:bold; }"); ss.addRule(".RangePart { color:#9900bb; }"); ss.addRule(".new { color:#009900; text-decoration:none; font-family:Courier New; }"); ss.addRule(".remove { color:#990000; text-decoration:none; font-family:Courier New; }"); ss.addRule(".rule { padding-left:10px; color:#333333;}"); } txtSchedule.setText(s.toString()); txtSchedule.addHyperlinkListener(this); updateFields(); }
protected void setStyleSheet() { if (isRawHtml) return; MultiMarkdownEditorKit htmlKit = new MultiMarkdownEditorKit(); final StyleSheet style = new MultiMarkdownStyleSheet(); if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) { style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false)); } else { try { style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)), null); } catch (IOException e) { e.printStackTrace(); } } htmlKit.setStyleSheet(style); jEditorPane.setEditorKit(htmlKit); }
public static void setStyleSheet(JEditorPane jEditorPane) { HTMLEditorKit htmlKit = new HTMLEditorKit(); final StyleSheet style = new StyleSheet(); if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) { style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false)); } else { try { style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)), null); } catch (IOException e) { e.printStackTrace(); } } htmlKit.setStyleSheet(style); jEditorPane.setEditorKit(htmlKit); }
/** Restore the background. * @param background The background to be restored. * @see #saveBackground() */ public void restoreBackground(Color background) { try { if (background != null) { // Restore the background color. String rgb = Integer.toHexString(background.getRGB()); String rule = "body {background: #" + rgb.substring(2, rgb.length()) + ";}"; StyleSheet styleSheet = _HTMLEditorKit.getStyleSheet(); styleSheet.addRule(rule); _HTMLEditorKit.setStyleSheet(styleSheet); } } catch (Exception ex) { log.error("Problem restoring background color. {}", ex); } }
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; } }
private JComponent createPackageDesignPrinciple(String path) { JEditorPane text = new JEditorPane(); text.setContentType("text/html;charset=utf-8"); text.setEditable(false); try { StyleSheet ss = new StyleSheet(); StyleSheet s1 = new StyleSheet(); s1.importStyleSheet(new URL(null, "classpath:/culture/包的设计原则_files/style.css", new ClassPathURLStreamHandler())); ss.addStyleSheet(s1); HTMLEditorKit kit = new HTMLEditorKit(); ss.addStyleSheet(kit.getStyleSheet()); kit.setStyleSheet(ss); text.setEditorKit(kit); text.setPage(new URL(null, "classpath:/culture/" + path, new ClassPathURLStreamHandler())); text.setCaretPosition(0); } catch (Exception e) { e.printStackTrace(); } return new JScrollPane(text); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") private static void patchStyledEditorKit() { try { StyleSheet defaultStyles = new StyleSheet(); InputStream is = DarculaLaf.class.getResourceAsStream("darcula.css"); Reader r = new BufferedReader(new InputStreamReader(is, "UTF-8")); defaultStyles.loadRules(r, null); r.close(); final Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY"); keyField.setAccessible(true); final Object key = keyField.get(null); AppContext.getAppContext().put(key, defaultStyles); } catch (Exception e) { log(e); } }
private void setHTMLFontSize(JTextPane tp){ HTMLEditorKit ek; try{ ek=(HTMLEditorKit)tp.getEditorKitForContentType("text/html"); } catch (Exception e) { return; } if(ek==null) return; //En las VMS antiguas no funciona bien ek.setLinkCursor(new Cursor(Cursor.HAND_CURSOR)); StyleSheet css= getCssBase(); StyleSheet cssOriginal= ek.getStyleSheet(); String styleSize="body{font-size : "+ (int)(100+((getFontSizeSlider().getValue()-14)/48.)*100)+"%;}"; cssOriginal.addStyleSheet(css); cssOriginal.addStyle(styleSize, cssOriginal.getRule("body")); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") private static void patchStyledEditorKit() { try { StyleSheet defaultStyles = new StyleSheet(); InputStream is = DarculaLaf.class.getResourceAsStream("darcula.css"); Reader r = new BufferedReader(new InputStreamReader(is, "UTF-8")); defaultStyles.loadRules(r, null); r.close(); final Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY"); keyField.setAccessible(true); final Object key = keyField.get(null); AppContext.getAppContext().put(key, defaultStyles); } catch (Throwable e) { log(e); } }
/** * This method creates and returns a stylesheet that makes the documentation look as it's supposed to look. * * @return the stylesheet */ private StyleSheet createStyleSheet() { StyleSheet css = new HTMLEditorKit().getStyleSheet(); css.addRule("* {font-family: Arial}"); css.addRule("p {padding: 0px 20px 1px 20px; font-family: Arial;}"); css.addRule("ul li {padding-bottom:1ex}"); css.addRule("hr {color:red; background-color:red}"); css.addRule("h3 {color: #3399FF}"); css.addRule("h4 {color: #3399FF; font-size:13pt}"); css.addRule("h4 img {margin-right:8px;}"); css.addRule(".typeIcon {height: 10px; width: 10px;}"); css.addRule("td {vertical-align: top}"); css.addRule(".lilIcon {padding: 2px 4px 2px 0px}"); //css.addRule(".HeadIcon {height: 40px; width: 40px}"); css.addRule("td {font-style: normal}"); return css; }
public static void installDefaultStylesheet(StyleSheet css ) { css.addRule("body {font-family:Sans;font-size:12pt}"); css.addRule("h3 {margin:0; padding:0; }"); //String hcolor = Integer.toHexString(SwingTools.DARKEST_BLUE.darker().darker().darker().getRGB()); //hcolor = hcolor.substring(2, 8); String hcolor = "446699"; css.addRule("h4 {margin-bottom:1px; margin-top:2ex; padding:0; color:#"+hcolor+"; font-size:12px}"); //css.addRule("h2, h3, h4 { border-width:3px; border-style:solid; border-color:#"+Integer.toHexString(SwingTools.RAPID_I_ORANGE.getRGB())+"; }"); css.addRule("p {margin-top:0; margin-bottom:2ex; padding:0}"); // css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image:url(" + Tools.getResource("icons/help/circle.png") + "); }"); css.addRule("ul.ports {margin-top:0; margin-bottom:1ex; list-style-image:url(" + Tools.getResource("icons/help/circle.png") + "); }"); css.addRule("ul li {padding-bottom:1ex}"); // css.addRule("li.outPorts {padding-bottom:0px}"); css.addRule("ul.param_dep {margin-top:0; margin-bottom:1ex; list-style-type:none; list-style-image:none; }"); // css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-type:none; list-style-image:none; }"); // css.addRule("ul li small ul {margin-top:0; list-style-type:none; list-style-image:none; }"); css.addRule("li ul li {padding-bottom:0}"); //css.addRule("a {text-decoration:none}"); //css.addRule("a:hover {text-decoration:underline}"); css.addRule("dt {font-weight:bold;}"); //css.addRule("a {text-decoration:underline; font-weight:bold;color:blue;}"); css.addRule("hr {color:red; background-color:red}"); }
public ExtendedHTMLEditorKit() { styleSheet = new StyleSheet(); try { InputStream is = HTMLEditorKit.class.getResourceAsStream(DEFAULT_CSS); Reader r = new BufferedReader(new InputStreamReader(is, "ISO-8859-1")); styleSheet.loadRules(r, null); r.close(); } catch (Exception e) { //LogService.getRoot().log(Level.WARNING, "Cannot install stylesheet: "+e, e); LogService.getRoot().log(Level.WARNING, I18N.getMessage(LogService.getRoot().getResourceBundle(), "com.rapidminer.gui.tools.ExtendedHTMLEditorKit.installing_stylesheet_error", e), e); // on error we simply have no styles... the html // will look mighty wrong but still function. } }
private Component makeMainLabel(String text) { JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text); StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet(); css.addRule("body {font-family:Sans;font-size:11pt}"); css.addRule("h3 {margin:0; padding:0}"); css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}"); css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}"); css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}"); css.addRule("ul li {padding-bottom: 2px}"); css.addRule("li.outPorts {padding-bottom: 0px}"); css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url(" + getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")"); css.addRule("li ul li {padding-bottom:0}"); // label.setOpaque(false); label.setEditable(false); label.setBackground(Color.WHITE); // label.setVerticalTextPosition(SwingConstants.TOP); // label.setHorizontalTextPosition(SwingConstants.LEFT); JScrollPane pane = new JScrollPane(label); pane.setBackground(Color.WHITE); pane.setBorder(null); return pane; }
public JeditorHtmlPanel(Document document) { jEditorPane = new JEditorPane(); scrollPane = new JBScrollPane(jEditorPane); // Setup the editor pane for rendering HTML. File baseDir = new File(""); VirtualFile parent = FileDocumentManager.getInstance().getFile(document).getParent(); if (parent != null) { // parent will be null if we use Language Injection and Fragment Editor baseDir = new File(parent.getCanonicalPath()); } final HTMLEditorKit kit = new AsciiDocEditorKit(baseDir); // Create an AsciiDoc style, based on the default stylesheet supplied by UiUtil.getHTMLEditorKit() // since it contains fix for incorrect styling of tooltips final String cssFile = isDarcula() ? "darcula.css" : "preview.css"; final StyleSheet customStyle = loadStyleSheet(JeditorHtmlPanel.class.getResource(cssFile)); final StyleSheet style = UIUtil.getHTMLEditorKit().getStyleSheet(); style.addStyleSheet(customStyle); kit.setStyleSheet(style); // jEditorPane.setEditorKit(kit); jEditorPane.setEditable(false); // use this to prevent scrolling to the end of the pane on setText() ((DefaultCaret)jEditorPane.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE); }
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; } }; }
private void style(JTextPane textPane) { StyleSheet styleSheet = ((HTMLDocument) textPane.getDocument()).getStyleSheet(); styleSheet.addRule("h2 {color: #663333; font-size: 102%; font-weight: bold; " + "margin-bottom:3px}"); styleSheet.addRule("h3 {color: #663333; font-size: 95%; font-weight: bold;" + "margin-bottom:7px}"); styleSheet.addRule("ul { list-style-type: none; margin-left: 5px; " + "padding-left: 1em; text-indent: -1em;}"); styleSheet.addRule("h4 {color: #66333; font-weight: bold; margin-bottom:3px;}"); // styleSheet.addRule("b {background-color: #FFFF00;}"); styleSheet.addRule(".bold {font-weight:bold;}"); styleSheet.addRule(".link {color:blue; text-decoration: underline;}"); styleSheet.addRule(".excerpt {font-size: 90%;}"); // highlight matching fragments styleSheet.addRule(".hitHL {background-color: #FFFF00;}"); }