Java Code Examples for javax.swing.JEditorPane#addMouseListener()
The following examples show how to use
javax.swing.JEditorPane#addMouseListener() .
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: LanguagesEditorKit.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void install (JEditorPane c) { super.install (c); HyperlinkListener hl = new HyperlinkListener (); c.addMouseMotionListener (hl); c.addMouseListener (hl); c.addKeyListener(hl); c.addCaretListener (new MarkOccurrencesSupport (c)); }
Example 2
Source File: SwingBoxEditorKit.java From SwingBox with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void install(JEditorPane c) { super.install(c); c.addMouseListener(mcontroller); c.addMouseMotionListener(mcontroller); component = c; }
Example 3
Source File: CheckForUpdateAction.java From nextreports-designer with Apache License 2.0 | 4 votes |
private JComponent createPanel(String html) { 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, 120)); editorPane.setEditable(false); editorPane.setContentType("text/html"); editorPane.setBackground(new Color(234, 241, 248)); Document doc = kit.createDefaultDocument(); editorPane.setDocument(doc); editorPane.setText(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; }