本文整理汇总了Java中javax.swing.text.html.StyleSheet.addRule方法的典型用法代码示例。如果您正苦于以下问题:Java StyleSheet.addRule方法的具体用法?Java StyleSheet.addRule怎么用?Java StyleSheet.addRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.html.StyleSheet
的用法示例。
在下文中一共展示了StyleSheet.addRule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postInitComponents
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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"));
}
示例2: createStyleSheet
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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;
}
示例3: makeMainLabel
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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;
}
示例4: buildStyleSheet
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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);
}
示例5: getHTMLEditorKit
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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;
}
};
}
示例6: createStyleSheet
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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;
}
示例7: makeMainLabel
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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;
}
示例8: ScheduleEditor
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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();
}
示例9: restoreBackground
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/** 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);
}
}
示例10: createStyleSheet
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
* 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;
}
示例11: installDefaultStylesheet
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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}");
}
示例12: makeMainLabel
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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;
}
示例13: getHTMLEditorKit
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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;
}
};
}
示例14: style
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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;}");
}
示例15: PanelBodyContainer
import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/** Creates new form InstallPanelContainer */
public PanelBodyContainer (String heading, String msg, JPanel bodyPanel) {
head = heading;
message = msg;
this.bodyPanel = bodyPanel;
initComponents ();
HTMLEditorKit htmlkit = new HTMLEditorKitEx();
// override the Swing default CSS to make the HTMLEditorKit use the
// same font as the rest of the UI.
// XXX the style sheet is shared by all HTMLEditorKits. We must
// detect if it has been tweaked by ourselves or someone else
// (code completion javadoc popup for example) and avoid doing the
// same thing again
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();
css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
}
tpPanelHeader.setEditorKit(htmlkit);
tpPanelHeader.putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
writeToHeader (head, message);
initBodyPanel ();
}