Java 8 JEditorPane - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JEditorPane class.

This code example shows how to use the following methods:setBackground, setBorder, setForeground, setPreferredSize, setContentType
		hPane.setContinuousLayout(true);
		hPane.setOneTouchExpandable(true);
		hPane.setDividerLocation(INITIAL_WIDTH - 200);
		add(hPane, BorderLayout.CENTER);
 
		componentData = new JEditorPane();
		componentData.setBackground(new Color(250, 250, 250));
		componentData.setForeground(new Color(33, 33, 33));
		componentData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
		componentData.setPreferredSize(new Dimension(INITIAL_WIDTH, 36));
		componentData.setEditable(false);
		componentData.setContentType("text/html");
		SwingUtil.enforceJEditorPaneFont(componentData, font);
		add(componentData, BorderLayout.SOUTH);
 
	} 
 
	/** 
	 * Reloads component tree completely. 
	 */ 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:putClientProperty, setBackground, setOpaque, setContentType, setEditorKit
     * Adapts a {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}. 
     * @param pane The editor pane to adapt 
     * @param allBold If {@code true}, makes all text to be displayed in bold 
     */ 
    public static void makeJLabelLike(JEditorPane pane, boolean allBold) {
        pane.setContentType("text/html");
        pane.setOpaque(false);
        pane.setEditable(false);
        adaptForNimbus(pane);
 
        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
        final Font f = UIManager.getFont("Label.font");
        final StyleSheet ss = new StyleSheet();
        ss.addRule((allBold ? "html" : "strong, b") + " {" + getFontRule(f) + "}");
        ss.addRule("a {text-decoration: underline; color: blue}");
        ss.addRule("h1 {" + getFontRule(GuiHelper.getTitleFont()) + "}");
        ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}");
        ss.addRule("ul {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: disc}");
        kit.setStyleSheet(ss);
        pane.setEditorKit(kit);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setSize, paint, setPreferredSize, setEditorKit, setPage
		Validate.isTrue(width > 0 && height > 0, "Invalid dimensions. Dimensions must be greater than 0.");
		 
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		 
		JEditorPane editorPane = createEditorPane(width, height);
		editorPane.setPage(htmlSource);
		editorPane.paint(image.getGraphics());
		 
		return image;
	} 
 
	/** 
	 * Create and return an image of the provided HTML content. The image will have 
	 * the provided dimensions. 
	 * <p/> 
	 * Note: This method will not change any styles to ensure that the html document will fit inside the 
	 * specified dimensions. 
	 */ 
	public static BufferedImage createImageFromHtml(String sourceHtml, int width, int height)
	{ 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBackground, addHyperlinkListener, setEditable
		if (linkMessage == null){
			linkMessage = "";
		} 
		 
		// html content 
		JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
				+ "<p>The device appears to have root access but does not have the ARO Collector installed.</p>" 
				+ line2
				+ linkMessage
				+ "</body></html>"); 
 
		// handle link events 
		ep.addHyperlinkListener(new HyperlinkListener() {
 
			@Override 
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
					// ProcessHandler.launchUrl(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+ 
 
					try { 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addHyperlinkListener, setEditorKit, setText, setEditable
    public MapdustHelpPanel() { 
        setLayout(new BorderLayout());
        String name = "Help";
        setName(name);
        String txt = buildText();
        JEditorPane txtHelp = new JEditorPane("text/html", "");
        txtHelp.setEditorKit(new HTMLEditorKit());
        txtHelp.setEditable(false);
        txtHelp.setText(txt);
        txtHelp.addHyperlinkListener(this);
        JScrollPane cmpDescription = ComponentUtil.createJScrollPane(txtHelp,
                null, Color.white, true, true);
        cmpDescription.setPreferredSize(new Dimension(100, 100));
        add(cmpDescription, BorderLayout.CENTER);
    } 
 
    @Override 
    public void hyperlinkUpdate(HyperlinkEvent event) {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            String url = Configuration.getInstance().getMapdustWiki();
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setMinimumSize, setEditorKit, setEditable
	public void actionPerformed(JTextComponent target, SyntaxDocument sDoc,
		int dot, ActionEvent e) {
		// find the abbreviations actions: 
		DefaultSyntaxKit kit = ActionUtils.getSyntaxKit(target);
		if (kit != null) {
			Map<String, String> abbs = kit.getAbbreviations();
			if (abbs == null || abbs.isEmpty()) {
				JOptionPane.showMessageDialog(target,
					java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ShowAbbsAction.NoAbbsForType"));
			} else { 
				new ShowAbbsDialog((JEditorPane) target, abbs);
			} 
		} 
	} 
} 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setContentType, setText, getDocument, setCaretPosition, setEditable
 
  protected void init() 
  { 
    setTitle(UtilMessages.getInstance().getString("SystemInformationDialog.Title")); 
 
    editorPane = new JEditorPane();
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");//NON-NLS
    editorPane.setText(getSystemInformationAsHTML());
    final HTMLDocument htmlDocument = (HTMLDocument) editorPane.getDocument();
    htmlDocument.getStyleSheet().addRule("body { font-family:sans-serif; }");//NON-NLS
    editorPane.setCaretPosition(0);
 
    super.init(); 
    getConfirmAction().putValue(Action.NAME, UtilMessages.getInstance().getString("SystemInformationDialog.Close"));
  } 
 
  protected void performInitialResize() 
  { 
    pack(); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setPage, setText, setEditable
{ 
	public HelpControlsPanel() 
	{ 
		super(new BorderLayout());
 
		JEditorPane editorPane = new JEditorPane();
		editorPane.setEditable(false);
		java.net.URL helpURL = this.getClass().getResource("/au/gov/ga/worldwind/data/help/controls");
		if (helpURL != null)
		{ 
			try 
			{ 
				editorPane.setPage(helpURL);
			} 
			catch (IOException e)
			{ 
				editorPane.setText(e.toString());
			} 
		} 
		else 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setPreferredSize, setPage, setText, setEditable
  { 
    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
 
    final InternalDemoHandler demoHandler = getDemoHandler();
    final JEditorPane editorPane = new JEditorPane();
    final URL url = demoHandler.getDemoDescriptionSource();
    editorPane.setEditable(false);
    editorPane.setPreferredSize(new Dimension(400, 200));
    if (url != null)
    { 
      try 
      { 
        editorPane.setPage(url);
      } 
      catch (IOException e)
      { 
        editorPane.setText("Unable to load the demo description. Error: " + e.getMessage());
      } 
    } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:putClientProperty, setOpaque, getPreferredSize, setEditable
                "  * Hardware Architecture: " + System.getProperty("os.arch") + "\n\n" +
        		"We are sorry for the trouble and thanks for reporting problems with JabRef!\n"; 
             
            System.out.println(errorMessage);
             
            JEditorPane pane = new JEditorPane("text/html", 
                "<html>The following error occurred while running JabRef:<p><font color=\"red\">" + 
                exceptionToString(e.getCause()).replaceAll("\\n", "<br>") + 
                "</font></p>" +  
                "<p>Please first check if this problem and a solution is already known. Find our...</p>" + 
                "<ul><li>...FAQ at <b>http://jabref.sf.net/faq.php</b> and our..." + 
                "<li>...user mailing-list at <b>http://sf.net/mailarchive/forum.php?forum_name=jabref-users</b></ul>" +  
                "If you do not find a solution there, please let us know about the problem by writing a bug report.<br>" + 
                "You can find our bug tracker at <b>http://sourceforge.net/tracker/?atid=600306&group_id=92314</b>.<br>"  + 
                "<ul><li>If the bug has already been reported there, please add your comments to the existing bug.<br>" + 
                "<li>If the bug has not been reported yet, then we need the complete error message given above<br>" + 
                "and a description of what you did before the error occured.</ul>" + 
                "We also need the following information (you can copy and paste all this):</p>" + 
                "<ul><li>Java Version: " + javaVersion +
                "<li>Java Vendor: " + javaVendor +  

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 JEditorPane Methods: