com.alee.laf.text.WebTextPane Java Examples

The following examples show how to use com.alee.laf.text.WebTextPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinkUtils.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    WebTextPane textPane = (WebTextPane) e.getComponent();
    StyledDocument doc = textPane.getStyledDocument();
    Element elem = doc.getCharacterElement(textPane.viewToModel(e.getPoint()));
    if (!elem.getAttributes().isDefined(URL_ATT_NAME))
        // not a link
        return;

    int len = elem.getEndOffset() - elem.getStartOffset();
    final String url;
    try {
        url = doc.getText(elem.getStartOffset(), len);
    } catch (BadLocationException ex) {
        LOGGER.log(Level.WARNING, "can't get URL", ex);
        return;
    }

    Runnable run = new Runnable() {
        @Override
        public void run() {
            WebUtils.browseSiteSafely(fixProto(url));
        }
    };
    new Thread(run, "Link Browser").start();
}
 
Example #2
Source File: LinkUtils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseMoved(MouseEvent e) {
    WebTextPane textPane = (WebTextPane) e.getComponent();
    StyledDocument doc = textPane.getStyledDocument();
    Element elem = doc.getCharacterElement(textPane.viewToModel(e.getPoint()));
    if (elem.getAttributes().isDefined(URL_ATT_NAME)) {
        textPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        textPane.setCursor(Cursor.getDefaultCursor());
    }
}
 
Example #3
Source File: WebTextPaneExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebTextPane textPane = new WebTextPane ( getStyleId () );
    textPane.setInputPrompt ( getPreviewLanguagePrefix () + "prompt" );
    return CollectionUtils.asList ( new WebScrollPane ( textPane ).setPreferredSize ( 200, 100 ) );
}
 
Example #4
Source File: WebTextPaneExample.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected List<? extends JComponent> createPreviewElements ()
{
    final WebTextPane textPane = new WebTextPane ( getStyleId () );
    textPane.setText ( "Sample\nmultiline\ntext" );
    return CollectionUtils.asList ( textPane.setPreferredWidth ( 200 ) );
}
 
Example #5
Source File: AboutDialog.java    From Spade with GNU General Public License v3.0 4 votes vote down vote up
public AboutDialog(JFrame frame)
{
	super(frame, "About Spade");
	this.setIconImage(GUIManager.ICON);
	this.center(400, 300);
	this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
	
	WebTextPane area = new WebTextPane();
	StyledDocument doc = area.getStyledDocument();
	
	addStylesToDocument(doc);
	
	append(doc, "Spade", "large");
	append(doc, "\n    Version: ", "bold");
	append(doc, Spade.getVersion().toString(), "regular");
	append(doc, "\n    Build Type: ", "bold");
	append(doc, Spade.BUILD_TYPE, "regular");
	append(doc, "\n    Released on: ", "bold");
	append(doc, Spade.RELEASED, "regular");
	append(doc, "\n\n", "regular");
	append(doc, "Spade is an open-source cross-platform raster graphics editor inspired by Paint.NET.", "regular");
	append(doc, "It was started, and is currently maintained by HeroesGrave.\n", "regular");
	append(doc, "\n", "regular");
	append(doc, "Links:\n", "large");
	append(doc, "    Github Repo:\n", "bold");
	append(doc, "        " + Spade.REPO_URL + "\n", "italic");
	append(doc, "    HeroesGrave Development:\n", "bold");
	append(doc, "        http://heroesgrave.github.io/\n", "italic");
	append(doc, "\n", "regular");
	append(doc, "Credits:\n", "large");
	append(doc, "    HeroesGrave\n", "regular");
	append(doc, "    Longor1996\n", "regular");
	append(doc, "    BurntPizza\n", "regular");
	append(doc, "    SuperDisk\n", "regular");
	append(doc, "    Gef4k\n", "regular");
	append(doc, "    MarkBernard\n", "regular");
	append(doc, "    pwnedary\n", "regular");
	
	area.setEditable(false);
	
	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(new JScrollPane(area), BorderLayout.CENTER);
	this.setResizable(false);
}