Java Code Examples for javax.swing.text.html.StyleSheet#loadRules()
The following examples show how to use
javax.swing.text.html.StyleSheet#loadRules() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtendedHTMLEditorKit.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
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. } }
Example 2
Source File: DarculaLaf.java From Darcula with Apache License 2.0 | 6 votes |
@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); } }
Example 3
Source File: Theme.java From darklaf with MIT License | 5 votes |
/** * Load the css style sheet used for html display in text components with a {@link * javax.swing.text.html.HTMLEditorKit}. * * @param loaderClass the class to resolve the location of the style sheet. * @return the {@link StyleSheet}. */ public final StyleSheet loadStyleSheetWithClass(final Class<?> loaderClass) { StyleSheet styleSheet = new StyleSheet(); try (InputStream in = loaderClass.getResourceAsStream(getResourcePath() + getPrefix() + "_styleSheet.css"); InputStreamReader inReader = new InputStreamReader(in, StandardCharsets.UTF_8); BufferedReader r = new BufferedReader(inReader)) { styleSheet.loadRules(r, null); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace()); } return styleSheet; }
Example 4
Source File: UIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static StyleSheet loadStyleSheet(@Nullable URL url) { if (url == null) return null; try { StyleSheet styleSheet = new StyleSheet(); styleSheet.loadRules(new InputStreamReader(url.openStream(), CharsetToolkit.UTF8), url); return styleSheet; } catch (IOException e) { getLogger().warn(url + " loading failed", e); return null; } }