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


Java HTMLEditorKit.getStyleSheet方法代码示例

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


在下文中一共展示了HTMLEditorKit.getStyleSheet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postInitComponents

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的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: PanelBodyContainer

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的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

示例3: initHistoryWidget

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
protected void initHistoryWidget() {
    HTMLEditorKit kit = new HTMLEditorKit() {
        @Override
        public ViewFactory getViewFactory() {
            return new WrapHTMLFactory();
        }
    };
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("body {text-align: left;}");
    styleSheet.addRule("div.my {font-size: 1.2rem; font-style: italic;}");
    styleSheet.addRule("div.error {color: red;}");
    styleSheet.addRule("img {max-width: 100%;}");
    try {
        styleSheet.importStyleSheet(
                new URL("http://dl.ieclipse.cn/r/smartim.css"));
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    }
    HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
    String initText = String.format(
            "<html><head></head><body>%s</body></html>", "欢迎使用SmartIM");
    historyWidget.setEditorKit(kit);
    historyWidget.setDocument(doc);
    // historyWidget.setText(initText);
    historyWidget.setEditable(false);
    historyWidget.setBackground(null);
    historyWidget.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                String desc = e.getDescription();
                if (!StringUtils.isEmpty(desc)) {
                    hyperlinkActivated(desc);
                }
            }
        }
    });
}
 
开发者ID:Jamling,项目名称:SmartQQ4IntelliJ,代码行数:40,代码来源:IMChatConsole.java

示例4: DetailsPanel

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的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

示例5: validate

import javax.swing.text.html.HTMLEditorKit; //导入方法依赖的package包/类
private static void validate() throws Exception {
    AppContext appContext = AppContext.getAppContext();

    assertTrue(DTD.getDTD(DTD_KEY).getName().equals(DTD_KEY), "DTD.getDTD() mixed AppContexts");

    // Spoil hash value
    DTD invalidDtd = DTD.getDTD("invalid DTD");

    DTD.putDTDHash(DTD_KEY, invalidDtd);

    assertTrue(DTD.getDTD(DTD_KEY) == invalidDtd, "Something wrong with DTD.getDTD()");

    Object dtdKey = getParserDelegator_DTD_KEY();

    assertTrue(appContext.get(dtdKey) == null, "ParserDelegator mixed AppContexts");

    // Init default DTD
    new ParserDelegator();

    Object dtdValue = appContext.get(dtdKey);

    assertTrue(dtdValue != null, "ParserDelegator.defaultDTD isn't initialized");

    // Try reinit default DTD
    new ParserDelegator();

    assertTrue(dtdValue == appContext.get(dtdKey), "ParserDelegator.defaultDTD created a duplicate");

    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();

    if (styleSheet == null) {
        // First AppContext
        styleSheet = htmlEditorKit.getStyleSheet();

        assertTrue(styleSheet != null, "htmlEditorKit.getStyleSheet() returns null");
        assertTrue(htmlEditorKit.getStyleSheet() == styleSheet, "Something wrong with htmlEditorKit.getStyleSheet()");
    } else {
        assertTrue(htmlEditorKit.getStyleSheet() != styleSheet, "HtmlEditorKit.getStyleSheet() mixed AppContexts");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:bug6938813.java


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