本文整理了Java中javax.swing.text.html.StyleSheet.loadRules()
方法的一些代码示例,展示了StyleSheet.loadRules()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyleSheet.loadRules()
方法的具体详情如下:
包路径:javax.swing.text.html.StyleSheet
类名称:StyleSheet
方法名:loadRules
暂无
代码示例来源:origin: Slowpoke101/FTBLaunch
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;
}
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* Sets the font used for HTML displays to the specified font. Components
* that display HTML do not necessarily honor font properties, since the
* HTML document can override these values. Calling {@code setHtmlFont}
* after the data is set will force the HTML display to use the font
* specified to this method.
*
* @param doc
* the HTML document to update
* @param font
* the font to use
* @throws NullPointerException
* if any parameter is {@code null}
*/
public static void setHtmlFont(HTMLDocument doc, Font font) {
String stylesheet = String.format(STYLESHEET, font.getName(),
font.getSize(), font.getName(), font.getSize());
try {
doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
} catch (IOException e) {
//this should never happen with our sheet
throw new IllegalStateException(e);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* Sets the font used for HTML displays to the specified font. Components
* that display HTML do not necessarily honor font properties, since the
* HTML document can override these values. Calling {@code setHtmlFont}
* after the data is set will force the HTML display to use the font
* specified to this method.
*
* @param doc
* the HTML document to update
* @param font
* the font to use
* @throws NullPointerException
* if any parameter is {@code null}
*/
public static void setHtmlFont(HTMLDocument doc, Font font) {
String stylesheet = String.format(STYLESHEET, font.getName(),
font.getSize(), font.getName(), font.getSize());
try {
doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
} catch (IOException e) {
//this should never happen with our sheet
throw new IllegalStateException(e);
}
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* Sets the font used for HTML displays to the specified font. Components
* that display HTML do not necessarily honor font properties, since the
* HTML document can override these values. Calling {@code setHtmlFont}
* after the data is set will force the HTML display to use the font
* specified to this method.
*
* @param doc
* the HTML document to update
* @param font
* the font to use
* @throws NullPointerException
* if any parameter is {@code null}
*/
public static void setHtmlFont(HTMLDocument doc, Font font) {
String stylesheet = String.format(STYLESHEET, font.getName(),
font.getSize(), font.getName(), font.getSize());
try {
doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
} catch (IOException e) {
//this should never happen with our sheet
throw new IllegalStateException(e);
}
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* Sets the font used for HTML displays to the specified font. Components
* that display HTML do not necessarily honor font properties, since the
* HTML document can override these values. Calling {@code setHtmlFont}
* after the data is set will force the HTML display to use the font
* specified to this method.
*
* @param doc
* the HTML document to update
* @param font
* the font to use
* @throws NullPointerException
* if any parameter is {@code null}
*/
public static void setHtmlFont(HTMLDocument doc, Font font) {
String stylesheet = String.format(STYLESHEET, font.getName(),
font.getSize(), font.getName(), font.getSize());
try {
doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
} catch (IOException e) {
//this should never happen with our sheet
throw new IllegalStateException(e);
}
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* Sets the font used for HTML displays to the specified font. Components
* that display HTML do not necessarily honor font properties, since the
* HTML document can override these values. Calling {@code setHtmlFont}
* after the data is set will force the HTML display to use the font
* specified to this method.
*
* @param doc
* the HTML document to update
* @param font
* the font to use
* @throws NullPointerException
* if any parameter is {@code null}
*/
public static void setHtmlFont(HTMLDocument doc, Font font) {
String stylesheet = String.format(STYLESHEET, font.getName(),
font.getSize(), font.getName(), font.getSize());
try {
doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
} catch (IOException e) {
//this should never happen with our sheet
throw new IllegalStateException(e);
}
}
代码示例来源:origin: ATLauncher/ATLauncher
sheet.loadRules(reader, null);
reader.close();
sheet.loadRules(reader, null);
reader.close();
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* Overriden to return our own slimmed down style sheet.
*/
@Override
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(styleChanges);
try {
defaultStyles.loadRules(r, null);
} catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* Overriden to return our own slimmed down style sheet.
*/
@Override
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(styleChanges);
try {
defaultStyles.loadRules(r, null);
} catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: freeplane/freeplane
/**
* Overriden to return our own slimmed down style sheet.
*/
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(ScaledHTML.styleChanges);
try {
defaultStyles.loadRules(r, null);
}
catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* Overriden to return our own slimmed down style sheet.
*/
@Override
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(styleChanges);
try {
defaultStyles.loadRules(r, null);
} catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* Overriden to return our own slimmed down style sheet.
*/
@Override
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(styleChanges);
try {
defaultStyles.loadRules(r, null);
} catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* Overriden to return our own slimmed down style sheet.
*/
@Override
public StyleSheet getStyleSheet() {
if (defaultStyles == null) {
defaultStyles = new StyleSheet();
StringReader r = new StringReader(styleChanges);
try {
defaultStyles.loadRules(r, null);
} catch (Throwable e) {
// don't want to die in static initialization...
// just display things wrong.
}
r.close();
defaultStyles.addStyleSheet(super.getStyleSheet());
}
return defaultStyles;
}
代码示例来源:origin: RPTools/maptool
HTMLDocument document = (HTMLDocument) getDocument();
StyleSheet style = document.getStyleSheet();
style.loadRules(new StringReader(cssText), null);
} catch (ParserException e) {
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
/**
* Method for loading a Stylesheet into the app
*/
private void openStyleSheet(File fileCSS) throws IOException {
if (fileCSS == null) {
fileCSS = getFileFromChooser(".", JFileChooser.OPEN_DIALOG, extsCSS, Translatrix
.getTranslationString("FiletypeCSS"));
}
if (fileCSS != null) {
String currDocText = jtpMain.getText();
htmlDoc = (ExtendedHTMLDocument) (htmlKit.createDefaultDocument());
styleSheet = htmlDoc.getStyleSheet();
URL cssUrl = fileCSS.toURL();
InputStream is = cssUrl.openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
styleSheet.loadRules(br, cssUrl);
br.close();
htmlDoc = new ExtendedHTMLDocument(styleSheet);
registerDocument(htmlDoc);
jtpMain.setText(currDocText);
jtpSource.setText(jtpMain.getText());
}
refreshOnUpdate();
}
代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared
doc.getStyleSheet().loadRules(
new java.io.StringReader(stylesheet),
null);
代码示例来源:origin: com.github.arnabk/pgslookandfeel
doc.getStyleSheet().loadRules(
new java.io.StringReader(stylesheet),
null);
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
styleSheet = htmlDoc.getStyleSheet();
BufferedReader br = new BufferedReader(new InputStreamReader(urlStyleSheet.openStream()));
styleSheet.loadRules(br, urlStyleSheet);
br.close();
htmlDoc = new ExtendedHTMLDocument(styleSheet);
内容来源于网络,如有侵权,请联系作者删除!