javax.swing.text.html.HTMLEditorKit#getStyleSheet ( )源码实例Demo

下面列出了javax.swing.text.html.HTMLEditorKit#getStyleSheet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-swing-tips   文件: MainPanel.java
private static JEditorPane makeEditorPane(HTMLEditorKit kit, String text) {
  JEditorPane editor = new JEditorPane();
  editor.setEditable(false);
  editor.setContentType("text/html");
  editor.setEditorKit(kit);
  editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  editor.setText(text);
  StyleSheet style = kit.getStyleSheet();
  style.addRule("span {color: orange;}");
  style.addRule("img {align: middle; valign: middle; vertical-align: middle;}");
  return editor;
}
 
源代码2 项目: Rel   文件: BrowserSwing.java
private void setEnhancedOutputStyle(JTextPane pane) {
	pane.setContentType("text/html");
	pane.setEditable(false);
	pane.setEnabled(true);
	HTMLEditorKit editorKit = new HTMLEditorKit();
	HTMLDocument defaultDocument = (HTMLDocument) editorKit.createDefaultDocument();
	pane.setEditorKit(editorKit);
	pane.setDocument(defaultDocument);
	StyleSheet css = editorKit.getStyleSheet();
	for (String entry : style.getFormattedStyle())
		css.addRule(entry);
}
 
源代码3 项目: java-swing-tips   文件: MainPanel.java
private MainPanel() {
  super(new GridLayout(3, 1));
  add(makeUrlPanel("Default", HREF));

  // Customize detault html link color in java swing - Stack Overflow
  // https://stackoverflow.com/questions/26749495/customize-detault-html-link-color-in-java-swing
  HTMLEditorKit kit = new HTMLEditorKit();
  StyleSheet styleSheet = kit.getStyleSheet();
  styleSheet.addRule("a{color:#FF0000;}");
  add(makeUrlPanel("styleSheet.addRule(\"a{color:#FF0000;}\")", HREF));

  add(makeUrlPanel("<a style='color:#00FF00'...", String.format("<html><a style='color:#00FF00' href='%s'>%s</a>", MYSITE, MYSITE)));

  setPreferredSize(new Dimension(320, 240));
}
 
源代码4 项目: netbeans   文件: PanelBodyContainer.java
/** 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 ();
}
 
源代码5 项目: WePush   文件: UpdateInfoDialog.java
public void setHtmlText(String htmlText) {
    textPane1.setContentType("text/html; charset=utf-8");
    HTMLEditorKit kit = new HTMLEditorKit();
    textPane1.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("h2{color:#FBC87A;}");
    styleSheet.addRule("body{font-family:" + buttonOK.getFont().getName() + ";font-size:" + buttonOK.getFont().getSize() + ";}");
    textPane1.setText(htmlText);
    textPane1.setCaretPosition(0);
}
 
源代码6 项目: WePush   文件: CommonTipsDialog.java
public void setHtmlText(String htmlText) {
    textPane1.setContentType("text/html; charset=utf-8");
    HTMLEditorKit kit = new HTMLEditorKit();
    textPane1.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("h2{color:#FBC87A;}");
    styleSheet.addRule("body{font-family:" + buttonOK.getFont().getName() + ";font-size:" + buttonOK.getFont().getSize() + ";}");
    textPane1.setText(htmlText);
}
 
源代码7 项目: bither-desktop-java   文件: Browser.java
public Browser(String currentHref) {
    super();

    this.currentHref = currentHref;


    try {
        if (Bither.getMainFrame() != null) {
            Bither.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }
        addHyperlinkListener(new ActivatedHyperlinkListener(Bither.getMainFrame(), this));

        loadingMessage = LocaliserUtils.getString("browser.loadingMessage");

        setEditable(false);
        setBackground(Themes.currentTheme.detailPanelBackground());

        String fontName = null;
        if (fontName == null || "".equals(fontName)) {
            fontName = ColorAndFontConstants.BITHER_DEFAULT_FONT_NAME;
        }
        // Add in san-serif as a fallback.
        fontName = fontName + ", san-serif";

        int fontSize = ColorAndFontConstants.BITHER_DEFAULT_FONT_SIZE;
        boolean isItalic = false;
        boolean isBold = false;
        Font adjustedFont = FontSizer.INSTANCE.getAdjustedDefaultFont();
        if (adjustedFont != null) {
            setFont(adjustedFont);
            fontSize = adjustedFont.getSize();
            isItalic = adjustedFont.isItalic();
            isBold = adjustedFont.isBold();
        }

        String fontCSS = "font-size:" + fontSize + "pt; font-family:" + fontName + ";";
        if (isItalic) {
            fontCSS = fontCSS + "font-style:italic;";
        } else {
            fontCSS = fontCSS + "font-style:normal;";
        }
        if (isBold) {
            fontCSS = fontCSS + "font-weight:bold;";
        } else {
            fontCSS = fontCSS + "font-weight:normal;";
        }

        HTMLEditorKit kit = new HTMLEditorKit();
        setEditorKit(kit);
        javax.swing.text.html.StyleSheet styleSheet = kit.getStyleSheet();
        styleSheet.addRule("body {" + fontCSS + "}");
        Document doc = kit.createDefaultDocument();
        setDocument(doc);

        log.debug("Trying to load '" + currentHref + "'...");
    } catch (Exception ex) {
        showUnableToLoadMessage(ex.getClass().getCanonicalName() + " " + ex.getMessage());
    }
}
 
源代码8 项目: netbeans   文件: DetailsPanel.java
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 );
}
 
源代码9 项目: org.alloytools.alloy   文件: SimpleGUI.java
/**
 * This method displays the about box.
 */
public Runner doAbout() {
    if (wrap)
        return wrapMe();

    // Old about message
    // OurDialog.showmsg("About Alloy Analyzer " + Version.version(), OurUtil.loadIcon("images/logo.gif"), "Alloy Analyzer " + Version.version(), "Build date: " + " git: " + Version.commit, " ", "Lead developer: Felix Chang", "Engine developer: Emina Torlak", "Graphic design: Julie Pelaez", "Project lead: Daniel Jackson", " ", "Please post comments and questions to the Alloy Community Forum at http://alloy.mit.edu/", " ", "Thanks to: Ilya Shlyakhter, Manu Sridharan, Derek Rayside, Jonathan Edwards, Gregory Dennis,", "Robert Seater, Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,", "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, and Uriel Schafer.");

    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("body {color:#000; font-family:Verdana, Trebuchet MS,Geneva, sans-serif; font-size: 10px; margin: 4px; }");
    styleSheet.addRule("h1 {color: blue;}");
    styleSheet.addRule("h2 {color: #ff0000;}");
    styleSheet.addRule("pre {font : 10px monaco; color : black; background-color: #C0C0C0; padding: 4px; margin: 4px; }");
    styleSheet.addRule("th {text-align:left;}");

    JTextPane ta = new JTextPane();
    ta.setEditorKit(kit);
    ta.setContentType("text/html");
    ta.setBackground(null);
    ta.setBorder(null);
    ta.setFont(new JLabel().getFont());
    // @formatter:off
    ta.setText("<html><h1>Alloy Analyzer " + Version.getShortversion() + "</h1>"
    + "<br/>"
    + "<html>"
    + "<tr><th>Project Lead</th><td>Daniel Jackson</td></tr>"
    + "<tr><th>Chief Developer</th><td>Aleksandar Milicevic</td></tr>"
    + "<tr><th>Kodkod Engine</th><td>Emina Torlak</td></tr>"
    + "<tr><th>Open Source</th><td>Peter Kriens</td></tr>"
    + "</table><br/>"
    + "<p>For more information about Alloy, <a href='http://alloytools.org'>http://alloytools.org</a></p>"
    + "<p>Questions and comments about Alloy are welcome at the community forum:</p>"
    + "<p>Alloy Community Forum: <a href='https://groups.google.com/forum/#!forum/alloytools'>https://groups.google.com/forum/#!forum/alloytools</a></p>"
    + "<p>Alloy experts also respond to <a href='https://stackoverflow.com/questions/tagged/alloy'>https://stackoverflow.com</a> questions tagged <code>alloy</code>.</p>"
    + "<p>Major contributions to earlier versions of Alloy were made by: Felix Chang (v4);<br/>"
    + "Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater, Derek Rayside, Greg Dennis,<br/>"
    + "Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz Khurshid (v3); Manu Sridharan<br/>"
    + "(v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,<br/>"
    + "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, Uriel<br/>"
    + "Schafer (v1).</p>"
    + "<p>The development of Alloy was funded by part by the National Science Foundation under<br/>"
    + "Grant Nos. 0325283, 0541183, 0438897 and 0707612; by the Air Force Research Laboratory<br/>"
    + "(AFRL/IF) and the Disruptive Technology Office (DTO) in the National Intelligence<br/>"
    + "Community Information Assurance Research (NICIAR) Program; and by the Nokia<br/>"
    + "Corporation as part of a collaboration between Nokia Research and MIT CSAIL.</p>"
    + "<br/><pre>"
    + "Build Date: " + Version.buildDate() + "<br/>"
    + "Git Commit: " + Version.commit
    + "</pre>");
    // @formatter:on
    ta.setEditable(false);
    ta.addHyperlinkListener((e) -> {
        if (e.getEventType() == EventType.ACTIVATED) {
            if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (IOException | URISyntaxException e1) {
                    // ignore
                }
            }
        }
    });
    OurDialog.showmsg("About Alloy Analyzer " + Version.version(), ta);

    return null;
}
 
源代码10 项目: COMP3204   文件: ArtARDemo.java
@Override
public JPanel getComponent(int width, int height) throws IOException {
	final JPanel container = new JPanel();
	container.setSize(width, height);
	container.setPreferredSize(container.getSize());

	final OverlayLayout overlay = new OverlayLayout(container);
	container.setLayout(overlay);

	labelField = new JEditorPane();
	labelField.setOpaque(false);
	labelField.setSize(640 - 50, 480 - 50);
	labelField.setPreferredSize(labelField.getSize());
	labelField.setMaximumSize(labelField.getSize());
	labelField.setContentType("text/html");

	// add a HTMLEditorKit to the editor pane
	final HTMLEditorKit kit = new HTMLEditorKit();
	labelField.setEditorKit(kit);

	final StyleSheet styleSheet = kit.getStyleSheet();
	styleSheet.addRule("body {color:#FF00FF; font-family:courier;}");
	styleSheet.addRule("h1 {font-size: 60pt}");
	styleSheet.addRule("h2 {font-size: 50pt }");

	final Document doc = kit.createDefaultDocument();
	labelField.setDocument(doc);

	// final GridBagConstraints gbc = new GridBagConstraints();
	// gbc.gridy = 1;
	// panel.add(labelField, gbc);
	container.add(labelField);
	// labelField.setAlignmentX(0.5f);
	// labelField.setAlignmentY(0.5f);

	final JPanel panel = super.getComponent(width, height);
	container.add(panel);

	vc.getDisplay().addVideoListener(this);

	isRunning = true;
	new Thread(this).start();

	return container;
}
 
源代码11 项目: nextreports-designer   文件: AboutAction.java
private JComponent createPanel() {
	System.setProperty("awt.useSystemAAFontSettings", "on");
	final JEditorPane editorPane = new JEditorPane();    	
	HTMLEditorKit kit = new HTMLEditorKit();
	editorPane.setEditorKit(kit);
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    editorPane.setFont(new Font("Arial", Font.PLAIN, 12));
    editorPane.setPreferredSize(new Dimension(350, 180));
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");
    editorPane.setBackground(new Color(234, 241, 248));        
    // add some styles to the html
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule(".firstCol {margin-left: 25px; }");
    styleSheet.addRule(".secondCol {color: blue; }");
    Document doc = kit.createDefaultDocument();
    editorPane.setDocument(doc);
    editorPane.setText(
            "<html>" +
            "<body>" +
            "<table border='0px' BGCOLOR=\"#EAF1F8\">" +
            "<tr><td colspan=2>" +
            "<img src='" + ImageUtil.getImageURL("logo").toExternalForm() + "'>" +
            "</td></tr>" +
            "<tr><td class=\"firstCol\"><b>" + VERSION + "</b></td><td class=\"secondCol\">" + 
            	VERSION_NO + 
            "</td></tr>" +
            "<tr><td class=\"firstCol\"><b>" + BUILD + "</b></td><td class=\"secondCol\">" + 
            	ReleaseInfo.getBuildNumber() + " (" + BUILD_DATE + ")" + 
            "</td></tr>" +
            "<tr><td class=\"firstCol\"><b>" + SITE + "</b></td><td class=\"secondCol\">"+ 
            	"<a href=\"" + SITE_VALUE + "\">" + SITE_SMALL_VALUE + 
            "</a></td></tr>" +
            "<tr><td class=\"firstCol\"><b>" + COPYRIGHT + "</b></td><td class=\"secondCol\">" + 
            	DEVELOPER + 
            "</td></tr>" +
            "</table>" +
            "</body>" +
            "</html>"
    );

    // Add Hyperlink listener to process hyperlinks
    editorPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                        editorPane.setToolTipText(e.getURL().toExternalForm());
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {                            
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getDefaultCursor());
                        editorPane.setToolTipText(null);
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {       
            	    FileUtil.openUrl(e.getURL().toString(), AboutAction.class);                       
            }
        }
    });        
    editorPane.addMouseListener(mouseListener);
    JScrollPane sp = new JScrollPane(editorPane);       
    return sp;
}
 
源代码12 项目: openjdk-8   文件: bug6938813.java
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");
    }
}
 
源代码13 项目: jdk8u-jdk   文件: bug6938813.java
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");
    }
}
 
源代码14 项目: jdk8u_jdk   文件: bug6938813.java
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");
    }
}
 
源代码15 项目: dragonwell8_jdk   文件: bug6938813.java
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");
    }
}
 
源代码16 项目: jdk8u60   文件: bug6938813.java
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");
    }
}
 
源代码17 项目: openjdk-jdk8u   文件: bug6938813.java
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");
    }
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: bug6938813.java
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");
    }
}
 
源代码19 项目: openjdk-jdk9   文件: bug6938813.java
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");
    }
}
 
源代码20 项目: jdk8u-jdk   文件: bug6938813.java
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");
    }
}