当前位置: 首页>>代码示例>>Java>>正文


Java StyleSheet.addStyleSheet方法代码示例

本文整理汇总了Java中javax.swing.text.html.StyleSheet.addStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Java StyleSheet.addStyleSheet方法的具体用法?Java StyleSheet.addStyleSheet怎么用?Java StyleSheet.addStyleSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.html.StyleSheet的用法示例。


在下文中一共展示了StyleSheet.addStyleSheet方法的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"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BrokenPlatformCustomizer.java

示例2: 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;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UIUtil.java

示例3: createPackageDesignPrinciple

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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);
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:27,代码来源:DesignPrinciplePanel.java

示例4: setHTMLFontSize

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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"));

}
 
开发者ID:jcrodriguez-dis,项目名称:ACodeEditor,代码行数:19,代码来源:Main.java

示例5: JeditorHtmlPanel

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
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);
}
 
开发者ID:asciidoctor,项目名称:asciidoctor-intellij-plugin,代码行数:27,代码来源:JeditorHtmlPanel.java

示例6: 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;
        }
    };
}
 
开发者ID:JetBrains,项目名称:jediterm,代码行数:22,代码来源:UIUtil.java

示例7: createDefaultDocument

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
@Override
public Document createDefaultDocument() {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new StyleSheet();

    ss.addStyleSheet(styles);

    HTMLDocument doc = new CustomHTMLDocument(ss);
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(4);
    doc.setTokenThreshold(100);
    return doc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:OverviewControllerUI.java

示例8: 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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:PanelBodyContainer.java

示例9: createDefaultDocument

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
/**
 * Sets the async policy to flush everything in one chunk, and
 * to not display unknown tags.
 */
public Document createDefaultDocument(Font defaultFont,
                                          Color foreground) {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new StyleSheet();
    ss.addStyleSheet(styles);
    BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
    doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
    doc.setPreservesUnknownTags(false);
    return doc;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:15,代码来源:BasicHyperlinkUI.java

示例10: createDefaultDocument

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
@Override
public Document createDefaultDocument() {
	StyleSheet styles = getStyleSheet();
	StyleSheet ss = new ScaledStyleSheet();
	ss.addStyleSheet(styles);
	HTMLDocument doc = new HTMLDocument(ss);
	doc.setParser(getParser());
	doc.setAsynchronousLoadPriority(4);
	doc.setTokenThreshold(100);
	return doc;
}
 
开发者ID:Actelion,项目名称:openchemlib,代码行数:12,代码来源:ScaledEditorKit.java

示例11: createDefaultDocument

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
public Document createDefaultDocument()
{
	StyleSheet styles = getStyleSheet();
	StyleSheet ss = new StyleSheet();
	ss.addStyleSheet(styles);
	ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
	doc.setParser(getParser());
	doc.setAsynchronousLoadPriority(4);
	doc.setTokenThreshold(100);
	return doc;
}
 
开发者ID:dasatti,项目名称:urduhtmlmaster,代码行数:12,代码来源:ExtendedHTMLEditorKit.java

示例12: createDefaultDocument

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
public Document createDefaultDocument() {
	StyleSheet styles = getStyleSheet();
	StyleSheet ss = new StyleSheet();
	ss.addStyleSheet(styles);
	ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
	doc.setParser(getParser());
	doc.setAsynchronousLoadPriority(4);
	doc.setTokenThreshold(100);
	return doc;
}
 
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:11,代码来源:ExtendedHTMLEditorKit.java

示例13: createStyleSheet

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
public static StyleSheet createStyleSheet() {
  StyleSheet style = new StyleSheet();
  style.addStyleSheet(isUnderDarkTheme() && !isUnderGTKLookAndFeel() ? (StyleSheet)UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
  style.addRule("code { font-size: 100%; }"); // small by Swing's default
  style.addRule("small { font-size: small; }"); // x-small by Swing's default
  return style;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:UIUtil.java

示例14: DetailsPanel

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
public DetailsPanel() {
    initComponents2();
    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);
    }
    
    setEditorKit(htmlkit);
    addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hlevt) {
            if (EventType.ACTIVATED == hlevt.getEventType()) {
                if (hlevt.getURL () != null) {
                    Utilities.showURL(hlevt.getURL());
                }
            }
        }
    });
    setEditable(false);
    setPreferredSize(new Dimension(300, 80));
    RP.post(new Runnable() {

        @Override
        public void run() {
            getAccessibleContext ().setAccessibleName (
                    NbBundle.getMessage (DetailsPanel.class, "ACN_DetailsPanel")); // NOI18N
        }
    });

    putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:DetailsPanel.java

示例15: getTraceListJComponent

import javax.swing.text.html.StyleSheet; //导入方法依赖的package包/类
private JComponent getTraceListJComponent() {

		HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
		StyleSheet htmlStyleSheet = htmlEditorKit.getStyleSheet();
		htmlStyleSheet.addStyleSheet(styleSheet);

		JEditorPane traceListJEditorPane = new JEditorPane();
		traceListJEditorPane.setEditable(false);
		traceListJEditorPane.setContentType("text/html");
		traceListJEditorPane.setEditorKitForContentType("text/html", htmlEditorKit);

		StringBuffer htmlStringBuffer = new StringBuffer();

		htmlStringBuffer.append("<H3 align='center'>" + LogEntryColumn.TRACELIST.getDisplayName() + "</H3>");

		int columnIndex = logEntryColumnList.indexOf(LogEntryColumn.TRACELIST.getColumnId());

		if (columnIndex != -1) {

			List<String> logEntryValueList = logEntryData.getLogEntryValueList();

			String traceListData = logEntryValueList.get(columnIndex);

			if ((traceListData != null) && (!"".equals(traceListData)) && (!"NA".equals(traceListData))) {
				String[] traceListArray = traceListData.split(";");

				List<TableData> traceListDataList = new LinkedList<TableData>();

				for (String traceList : traceListArray) {

					String[] traceListNameValue = traceList.split(":", 2);

					String nameColumn = traceListNameValue[0];
					String valueColumn = null;
					boolean isHREF = false;

					if (traceListNameValue.length > 1) {
						valueColumn = traceListNameValue[1];
					}

					TableData tableData = new TableData(nameColumn, valueColumn, isHREF);

					traceListDataList.add(tableData);
				}

				String traceListTableStr = getTableHTMLStr("Trace List", traceListDataList, "border=\"1\"");

				htmlStringBuffer.append(traceListTableStr);

				traceListJEditorPane.setText(htmlStringBuffer.toString());
			}
		}

		GridBagConstraints gbc1 = new GridBagConstraints();
		gbc1.gridx = 0;
		gbc1.gridy = 0;
		gbc1.weightx = 1.0D;
		gbc1.weighty = 1.0D;
		gbc1.fill = GridBagConstraints.BOTH;
		gbc1.anchor = GridBagConstraints.NORTHWEST;
		gbc1.insets = new Insets(2, 15, 2, 2);

		JPanel traceListJPanel = new JPanel();
		traceListJPanel.setLayout(new GridBagLayout());

		traceListJPanel.add(traceListJEditorPane, gbc1);
		traceListJPanel.setBackground(Color.WHITE);
		traceListJPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));

		JScrollPane traceListJScrollPane = new JScrollPane(traceListJPanel,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		traceListJScrollPane.getVerticalScrollBar().setUnitIncrement(16);

		return traceListJScrollPane;
	}
 
开发者ID:pegasystems,项目名称:pega-logviewer,代码行数:77,代码来源:AlertLogEntryPanel.java


注:本文中的javax.swing.text.html.StyleSheet.addStyleSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。