Mouse Cursor over Hyperlink

How can i change the mouse cursor when the user is floating over a hyperlink, i am currently using a Hyperlink listener:
new HyperlinkListener() {
                    public void hyperlinkUpdate(HyperlinkEvent e)
                         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                              getThePage(e.getURL().toString());
               }

Here is a small example demonstrating how to change the cursor in a TextArea:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class TxtDemo extends Frame implements ActionListener {
    TextField textField;
    TextArea textArea;
    String newline;
    public static void main(String[] args) {
        Frame F=new TxtDemo("Test Window");
        F.pack();
        F.setVisible(true);
        F.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
               System.exit(0);
    TxtDemo(String title) {
        super(title);
        textField = new TextField(20);
        textArea = new TextArea(5, 20);
        textArea.setEditable(false);
        textArea.setCursor (Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  // see here
        GridBagLayout gridBag = new GridBagLayout();
        setLayout(gridBag);
        GridBagConstraints c = new GridBagConstraints();
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.HORIZONTAL;
        gridBag.setConstraints(textField, c);
        add(textField);
        c.fill = GridBagConstraints.BOTH;
        c.weightx = 1.0;
        c.weighty = 1.0;
        gridBag.setConstraints(textArea, c);
        add(textArea);
        textField.addActionListener(this);
        newline = System.getProperty("line.separator");
    public void actionPerformed(ActionEvent evt) {
        String text = textField.getText();
        textArea.append(text + newline);
        textField.selectAll();
}Hope this helps..
;o)
V.V.

Similar Messages

  • Mouse cursor ignores hyperlink

    Hello:
    1st time poster.
    Computer: 
      Toshiba Satelite: P105
      MS XP Media Center Edition
      Version 2002
      Service Pack 3
       T5500 @ 1.66 GHz
       1.67 GHz, 0.99 GB of Ram
     I've had this thing for +/- 2 years, provided excellent service.
    Problem:  Several months ago, started doing what subject describes... cursor will not indicate it's over a hyperlink, nor will it respond when cursor is over a hyperlink.  This behavior begins after indeed clicking 1 or more hyperlinks w/in a given page... then, no response as described.
    If I move mouse cursor outside of browser, click anything else (eg: desktop icon, start menu etc.) then go back to same web page, it will correctly show a hyperlink cursor for 1 or more clicks, then resume ignoring them as described.
    Very annoying.  Any help appreciatted.

    What about links in other applications (e.g., other browsers, email programs, word processors)?
    I didn't check any windows other than IE/FireFox... both of which exhibit same behavior.  I'll ask him to check & let me know.
    Thanks again for attention.
    FWIW, I've been writing code for MS OS(s) for 18+ yrs... never seen this one before (that's why it caught my interest).  I'm a little stumped. The code handling mouse action, although written for each individual program, relies on OS services almost entirely.  The OS messaging is the same for all those windows, whether a browser or resident EXE.  And playing with it this morning, the behavior is more
    consistent then he (Tobi) indicated:
     - Hyperlink works only once w/in browser window, then ignores hyperlinks.   As 1st mentioned, a click anywhere outside affected window will restore function for -1- click.
     - Same for scroll bar, min/maximze/close buttons, and any buttons I tried w/in several different web pages.  Again w/buttons, same a above: -1- click & it's DOA.

  • Change mouse cursor over graph cursor.

    Is there a way to change the mouse cursor as it moves over graph cursors when using trackmode TrackDragCursor? To indicate that you can position the cursor.

    You could accomplish this with the graph's CursorMouseMove event. For example, create a new project with the NI Measurement Studio AppWizard and follow these steps:
    Add a graph to the dialog. Right-click on the graph in the dialog editor, click "Class Wizard ...", click the Member Variables tab and add a member variable for the graph called m_graph. Click OK.
    Right-click on the graph in the dialog editor and click on "Events ...". Add an event handler for CursorMouseMove called OnCursorMouseMove and add an event handler for PlotAreaMouseMove called OnPlotAreaMouseMove. Click OK.
    Go to the header file for your dialog class and add this to the bottom of the class declaration:
    private:
    bool m_cursorChanged;
    HCURSOR m_defaultCursor;
    HCURSOR m_crossCursor;
    Go to the source file for your dialog class and add this to the end of the
    OnInitDialog method:
    m_graph.TrackMode = CNiGraph::TrackAllEvents;
    m_graph.Cursors.Add();
    m_cursorChanged = false;
    m_defaultCursor = ::LoadCursor(NULL, IDC_ARROW);
    m_crossCursor = ::LoadCursor(NULL, IDC_CROSS);
    Add this to your CursorMouseMove event hander:
    if (!m_cursorChanged)
    :etCursor(m_crossCursor);
    m_cursorChanged = false;
    Add this to your PlotAreaMouseMove event handler:
    if (m_cursorChanged)
    :etCursor(m_defaultCursor);
    m_cursorChanged = true;
    Run the application. You should see that the mouse cursor changes to a cross when you mouse over the cursor.
    Hope this helps.
    - Elton

  • Mouse cursor over button

    Is it possible to change the mouse cursor when hovering over a button in encore menu?

    Thanks for the concern, Bill. I already understood it. It was En's way of differentiating menu links from another objects like simple backgrounds that I was worried aboutits cursorwhich I thought was that it would be anywhere my video will be played because it is what it was when I built my video. It's purely Encore's.
    But I've got new problems to ask help for, just tell me if I have to make a new thread but I will just put it here for the mean time:
    I wanted to make chapter indices. When I first made the command "Create Chapter Index", En said the menu does not contain a previous button so it has to make it for me, I clicked ok. But then it generated a "General Application error" message and, eventually failed to make the chapter index. I checked my project and found no error. What's the likely cause of this?

  • [SOLVED]Mouse cursor changes between applications

    Hi, everyone this thing is driving me crazy. I'm still searching for some good solution for this.
    When i move the mouse cursor over a kde or java application (using gnome) the cursor changes to the system default, that black ugly thing. I know there is a way to do it by changing the default cursor theme, but when i do it kde and java applications don't launch. Someone please explain this on easy words, or some other solution please!
    Last edited by Hyugga (2010-05-16 03:38:12)

    Try to set Xcursor theme in ~/.Xdefaults
    $ grep Xcursor ~/.Xdefaults
    Xcursor.theme: Neutral_Plus
    Works for me in DWM
    Last edited by oew (2010-05-15 04:48:42)

  • Mouse cursor problem (dock magnification, highlight issue)

    My logitech wired USB mouse has an issue with my iMac.  It worked for a couple weeks.  After then, whenever it is plugged in, it does not magnify the dock, nor highlight things correctly (cursor does not turn into hand over links, does not open nor highligh menus unless clicked, etc).
    After searching, this problem has dated back years and across OS X versions, usually having to do with a wireless or wired Logitech mouse (which mine is).  The first thing people suggest is restarting/killing dock, re-install OS, repair permissions, among other things.  This rarely fixes the issue.  The solution that seems to fix it for most people is to simply unplug the mouse and plug it back in.  Most people state this fixes it until it happens again a week later and either they do the unplug-plug again or just give up and switch to another mouse.
    I have tried re-plugging it back in but it doesn't solve the issue.  Other mice work just fine which I've have gone to, but I really want to use that mouse (plus, I hate giving up!)
    Can anyone help me?  I'd appreciate it!  Thank you!
    EDIT: Here are some more clues to the puzzle:
    - The mouse works fine on multiple other computers
    - Other people have described this problem as the iMac no longer knows where the mouse cursor is until a mouse-click is pressed.  That is why it doesn't open menus, magnify the dock, change into a hand when hovering over a link, etc.  To open and select a menu at the top of the screen, for example, the left mouse button must be clicked and held, then let go of when you want to choose something.
    Message was edited by: vsonline11
    Message was edited by: vsonline11

    zmbmartin wrote:I have a problem with webkit based browser and was wondering if someone else had the same problem and/or had some ideas on how to fix it. In webkit browsers my mouse/cursor does not respond to state changes. So when I hover over a link the mouse/cursor does not change to a hand or when I hover over a text box it doesn't change to the text cursor. It is really annoying. If I do click on a link after I click the cursor turns into a hand and then stays that way no matter what I hover over.
    Just a remark:
    I'm also facing a similar problem running chromium on 32-bit arch with KDE. When I move the mouse cursor over the edges/corners of the browser the mouse cursor changes state (so a s to show arrows used for changing windows size) but uses the default X11 theme instead of my KDE mouse cursor theme....
    Also I'm using gtk-kde4 for gtk apps in KDE.
    Last edited by bhadotia (2011-01-10 15:22:27)

  • Hand cursor not displayed when mouse is over JEditorPane hyperlinks in 1.5

    Java version 1.5 does not show a hand cursor when the user mouses over a hyperlink within a JEditorPane, which it did in version 1.4.x.
    Create a new JEditorPane. Then set the content type (setContentType) as "text/html". Then use setText to add an html hyperlink. When the user mouses over the hyperlink, the cursor remains a pointer cursor. The cursor used to change into a hand cursor symbolizing a hyperlink.
    p.s.) The hyperlink still works, the cursor just doesn't change.
    Has anyone noticed this? Has it been reported as a bug? Is there a workaround?
    Thanks for any/all help!

    I have the same problem which I cannot seem to solve. I have a JEditorPane in a JDialog, not a JFrame, and I do not get a Hand cursor over the link. If I use a JFrame, I get the hand cursor.
    Any ideas? I tried with setting the cursor by hand using
    pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); in the ENTERED-part of a slightly more advanced hyperlink listener (gets pane in constructor). But that did not help either.
    Here is the code. Check out the difference between JDialog and JFrame.
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.awt.*;
    public class HyperLink extends JDialog
         public static void main(String[] args)
              HyperLink h = new HyperLink();
              h.setVisible(true);
         public HyperLink()
              Container cp = getContentPane();
              JEditorPane p = new JEditorPane("text/html",
                                  "<html><body><a href='http://www.google.com'>Google</a></body></html>");
              p.addHyperlinkListener(new HyperlinkListener() {
                   public void hyperlinkUpdate(final HyperlinkEvent he) {
                       HyperlinkEvent.EventType type = he.getEventType();
                       if (type == HyperlinkEvent.EventType.ENTERED) {
                        System.err.println("entered");
                       else if (type == HyperlinkEvent.EventType.EXITED) {
                        System.err.println("Exited");
                       else if (type == HyperlinkEvent.EventType.ACTIVATED) {
                        System.err.println("Now going to " + he.getURL());
              p.setEditable(false);
              cp.add( p );
              pack();
    }

  • Mouse cursor appearing as an arrow instead of a hand over album links

    Hi. I've just published my iWeb 08 site on .Mac (using Zone Edit to set up the CNAME for my personal domain, purchased from Last Digital). For some reason, when I hover over the links in the My Albums page, the mouse cursor appears as an arrow instead of the usual hand cursor. This has already confused a few of my testers, as obviously people are conditioned to expect a link where they see a hand. The links themselves work fine, it's just that the mouse cursor makes it look like they're not links. Does anyone know how this can be fixed so that the hand appears when you hover over each image? You can see the page in question here - http://www.paulinelockie.com/Pauline_Lockie/Portfolio/Portfolio.html

    That's the way it is.
    When you have multiple images in an album, and move the pointer over the album, you see the images displayed.
    Since it is not really a link, a pointer is used instead of the hand. It's a design decision.
    Send a feedback to the iWeb team.

  • Mouse cursor flicker (over links)

    When moving over links, the mouse cursor very quickly flickers when changing from the arrow to hand pointer.
    I've uploaded a slow-mo clip http://youtu.be/ZNQ0D84DdF4 which best demonstrates exactly what's happening.  I had to film using a camera as the screen recorder was not quick enough capture the flicker.
    This happens in all browsers and even the App Store app.

    Another update, I have a software fix - by editing the info.plist file for the pointinghand cursor to alter the x/y positions.
    System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HI Services.framework/Versions/A/Resources/cursors/pointinghand/info.plist
    I made changes to hoty, hoty-scaled, hotx and hotx-scaled and after some trial and error managed to get rid of the flicker and still have the hand cursor appear in the correct place on rollover/out
    values i used are :
    hoty 6
    hoty-scaled 10
    hotx 8
    hotx-scaled 12
    I used xcode to edit the plist file, then a restart for the changes to take effect.

  • Lion OS x 10.7 does not show me url drop down boxes when I mouse over hyperlinks

    Lion 10.7 does not show me url drop down boxes whenever I mouse over hyperlinked text in Gmail.
    Is there a setting I missed?  Does anyone have any idea why this might be?
    Thanks,
    lenms

    ANY one?    
    Any constructive comments would be appreciated.
    Thanks,
    lenms

  • Mouse cursor moving mask over another image.

    Hi, Is it possible to have where the Mouse cursor is on the page moving mask over another image. Imagine a black screen with a star cut out of the middle(where the cursor is) and u can see the image behind.
    Any examples on how to do this?
    Can it be done in html instead?

    Create the mask and the background as movieclips and then assign the mask as the mask property of the bacground movieclip... as in background.mask = msk (where msk is the instance name of the mask).
    Then assign a MOUSE_MOVE event listener to the mask and in the event handler for that listener have its x and y properties assigned to be the mouseX and mouseY properties

  • Does anyone know why my mouse cursor jumps all over the screen at times?

    Does anyone know why the mouse cursor jumps all over the screen at times, especially if I am playing solitare?  Is it Yahoo games or my Apple?

    Is this a Magic Mouse you're talking about?
    If so there's already discussions about this here and maybe related to it, here.  Also google something like "jumping magic mouse" and there's no end of discussions on this topic

  • Mouse cursor doesnt change to splitter over JTable column header.

    Hi, this problem seems to be fixed in 1.6 but does anybody know a work around in 1.5 on Windows XP?
    I'm afraid that I haven't been able to locate the relevant bug fix (if any) despite my best efforts with Google and searching these forums.
    The problem is that in 1.5 if the parent frame window is invisible then the mouse cursor doesn't change to the column splitter\resize icon when you hover the mouse between two columns on a column headers.
    If you run the following code under 1.5.0.7, you don't get the cursor change, if you change f.setVisible(false) to f.setVisible(true) then it works.
    public class ColumnResizeTest
        public static void main(String[] args)
            JFrame f = new JFrame("This is a test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(400, 200);
            f.setVisible(false); // change to true to get resize mouse cursor
            test(f);
        public static void test(Frame f)
            JPanel contentPanel = new JPanel(new BorderLayout());
            JDialog d = new JDialog(f);
            d.setSize(200, 400);
            contentPanel.add(new JScrollPane(new JTable(new DefaultTableModel(5, 5))), BorderLayout.CENTER);
            d.setContentPane(contentPanel);
            d.setVisible(true);
    }In my application at the point the JTable is displayed, the application frame is always invisible as the JTable is shown from the splash\login screen.
    Thanks in advance.
    Philip Wilkinson.

    Adding a mouse listener to either a cell renderer or cell editor in a table the cell cursor will not work because it is the table which responds to mouse motion events - not the individual cell (at least in the case of MouseEntered and MouseExited).
    My solution to this was to add a MouseMotionListener listener to the table and and on the mouseMoved event I called a method which determined whether or not the cursor to display should be a hand cursor or the default cursor.
    For example:
    * Adds a mouse motion listener to the table.
    public void addTableMouseMotionListener()
        table.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseMoved(MouseEvent me) {
                displayColumnCursor(me);
    * Method to change cursor based on some arbitrary rule.
    protected void displayColumnCursor( MouseEvent me ) {
        Point p = me.getPoint();
        int column = columnAtPoint(p);
        int row = rowAtPoint(p);
        String columnName = getColumnName(column);
        if (columnName.equals("SOME_COLUMN")) {
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else {
            setCursor(Cursor.getDefaultCursor());
    }Hope this helps solve your problem.
    cheers
    Greg

  • Mouse cursor issues (changes back to arrow)

    I keep having this annoying issue with the cursor of my mouse. It works just fine for a while, but after few hours (usually working with PS, Illustrator etc.) there is this thing happening - if I want to resize a window, an Illustrator object, or if I move the cursor over a hyperlink - cursor changes from an arrow to a hand or whatever desired sign - but just for a second and goes back to arrow! It is highly annoying. :/
    Idk the source of this problem, but I might add that I once installed a patch for Yosemite, which changes Helvetica system font for Lucida Grande. I uninstalled it though...
    I use the latest MacBook Pro 13-inch with Yosemite.
    Many thanks.

    Same problem.
    My setup:
    MBP running OS X 10.9
    Apple TV running 6.0 (6646.65)
    Samsung HD TV
    It's only happening when I have mirroring turned on (not extended desktop), and when I have the mirrored resolution set to match the TV. The TV has a larger viewing area than my Macbook Pro. My MBP screen resolution is set to "Scaled: Best for retina"
    This started happening after the update to Mavericks.
    EDIT:
    This solved it for me: I had Air Display running in the background, and the new version of Air Display automatically tries to connect to devices when it's running. My iPad is out, and I think Air Display might have been trying to connect to it. I quit Air Display and the cursor issue is gone.
    Message was edited by: brassknucklenerd

  • How can I create a text pop up window in my Pages document? I want text to pop up when the reader hovers his/her cursor over a certain word.

    How can I create a text pop up window in my Pages document? I want text to pop up when the reader hovers his/her cursor over a certain word in the document. I am teacher. So for example when a student came to word he/she did not know, if he/she hovered the cursor over the word, a defintion or other information would appear.  You can do this in Word using bookmarks/hyperlinks but I can't figure this out in Pages. I can link it to another point in my Pages document but I just need the text to pop up - not take the reader to another location.  THANK YOU!!!!!!

    Have you tried Word for Mac?
    You will need to test if links survive export or printing to .pdf
    Peter

Maybe you are looking for