From 15b28b415d795d42ec2bbd32bed3b32fc216528f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 30 Aug 2011 23:22:59 +0200 Subject: [PATCH] Mouse change cursor shape when is moved over a URL. --- app/src/processing/app/syntax/JEditTextArea.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 3c1548fbd..72fb7bafd 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -17,6 +17,7 @@ import javax.swing.event.*; import javax.swing.text.*; import javax.swing.undo.*; import javax.swing.*; + import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.*; @@ -2025,7 +2026,19 @@ public class JEditTextArea extends JComponent select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY())); } - public void mouseMoved(MouseEvent evt) {} + final Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); + final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); + + public void mouseMoved(MouseEvent evt) { + int line = yToLine(evt.getY()); + int offset = xToOffset(line, evt.getX()); + boolean wantHandCursor = checkClickedURL(getLineText(line), offset) != null; + JComponent src = (JComponent) evt.getSource(); + if (wantHandCursor) + src.setCursor(handCursor); + else + src.setCursor(normalCursor); + } } class FocusHandler implements FocusListener