Change mouse pointer over selected text

I have a JTextArea and i want to change the default mouse pointer to the arrow pointer when the user points to a selected text. Just like the way JCreator works.!
Thanx

Try this :
Cursor textCursor = new Cursor(Cursor.TEXT_CURSOR);
Cursor arrowCursor = new Cursor(Cursor.DEFAULT_CURSOR );
textArea.setCursor(textCursor);
textArea.addMouseMotionListener(new MouseMotionAdapter() {
     public void mouseMoved(MouseEvent e) {
          int location = textArea.viewToModel(e.getPoint());
          if (textArea.getSelectionStart()<=location && location<textArea.getSelectionEnd()) {
               if (textArea.getCursor() != arrowCursor) {
                    textArea.setCursor(arrowCursor);
          else {
               if (textArea.getCursor()==arrowCursor) {
                    textArea.setCursor(textCursor);
});I hope this helps,
Denis

Similar Messages

  • I recently bought, from the original website of Adobe, Photoshop elements 13. However, when I go with my mouse pointer over the menu, It hangs or he works very slow. Does anyone have an idea how I can fix it? I have already downloaded updates, both from A

    I recently bought, from the original website of Adobe, Photoshop elements 13. However, when I go with my mouse pointer over the menu, It hangs or he works very slow. Does anyone have an idea how I can fix it? I have already downloaded updates, both from Adobe and Windows. I have a new pc with window 8.1.

    It could be a coincidence, but I rebooted the machine and (knock on wood) PSE13 seems to be working ok.

  • How to place the mouse pointer over the default button automatically ?

    I am not content with the mouse capability in Mac OS.
    In Windows I used to have a mouse seetting that automatically placed the mouse pointer over the default button in a dialogue box
    Any suggestion for a mouse app for more settings ? is there a free app ?

    You might try SteerMouse 4.1.5 or if all you want is this one feature then try LazyMouse 2.5.

  • Changing mouse pointer using setCursor()

    Hi- I've got a single threaded JFrame-based application in which I want to change the mouse pointer to indicate 'busy' when it's doing stuff eg. loading a file. So within my extended JFrame method for handling menu selections I've got:
    public class Layout extends JFrame
        // For items in the main menu
        // (the sub-class contains either a JMenuItem or JCheckBoxMenuItem).
        abstract class MenuItem implements ActionListener
            abstract JMenuItem menuItemAbs(); // get the menu item component
            abstract void handlerAbs(); // perform the menu's action
            // Menu item has been selected.
            public void actionPerformed(ActionEvent e)
                Cursor cursor = Layout.this.getCursor();
                Layout.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                handlerAbs();
                Layout.this.setCursor(cursor);
            }But the mouse pointer doesn't always change. If handler() just does some processing without user interaction, the pointer does change. But in the case of loading a file, where first the user selects the file using a JFileChooser, it doesn't.
    Is this because JFileChooser does its own setCursor()? But even if it does, presumably it does another setCursor() to restore my WAIT_CURSOR before it returns, so why don't I see the WAIT_CURSOR while the file is loading (which takes seconds)?
    Cheers
    John
    EDIT: BTW running under Linux, Java v6 update 7
    Edited by: matth1j on Nov 12, 2008 2:15 AM

    Ok, thanks - full demo program below.
    When you hit the ok button (just 5 second sleep), the mouse pointer changes to 'busy'. It reverts to normal if you move the pointer off the frame, but goes back to 'busy' if you move it back onto the frame.
    When you hit the bad button (brings up file chooser, then does 5 second sleep), the pointer changes to 'busy' while the pointer is over the frame, and reverts to normal when the pointer is moved off the frame. But if you select a file or cancel the file chooser and move the pointer back into the main frame before the 5 seconds is up, the pointer doesn't go back to 'busy' again. I would expect it to show 'busy' while over the frame until the 5 seconds is up.
    Any ideas?
    package test;
    import java.awt.Cursor;
    import java.awt.EventQueue;
    import java.awt.event.*;
    import javax.swing.*;
    public class Main
        public static void main(String[] args)
            EventQueue.invokeLater(new Runnable()
                public void run()
                    new Test();
    class Test extends JFrame
        public Test()
            super();
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            JPanel panel = new JPanel();
            panel.add(new Button("ok"));
            panel.add(new Button("bad"));
            add(panel);
            pack();
            repaint();
            setVisible(true);
        class Button extends JButton implements ActionListener
            Button(String text)
                super(text);
                addActionListener(this);
            public void actionPerformed(ActionEvent e)
                Cursor cursor = Test.this.getCursor();
                Test.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                if (!e.getActionCommand().equals("ok"))
                    (new JFileChooser()).showOpenDialog(null);
                try
                    Thread.sleep(5000);
                catch (Exception ex)
                    ex.printStackTrace();
                Test.this.setCursor(cursor);
    }Edited by: matth1j on Nov 12, 2008 2:44 AM code tidy
    Edited by: matth1j on Nov 12, 2008 2:45 AM code tidy

  • How to change mouse pointer to Arrow?

    When we move the mouse over any component in preview (or in SWF file), mouse pointer changes to u201Chandu201D. Is it possible to keep the mouse pointer to Arrow or any other custom mouse pointer in Xcelsius 2008 SP 4?
    Thanks

    Mouse over cursor is set to ARROW if the component is not selectable
    Eg:pie chard which has no drill down or no furthur selection is enabled then the mouse over by default is ARROW.
    If you have enabled any furthur selection for that component the by default mouseover is HAND .
    This holds good for all the components in Xcelsius (even in sp4) Except for tab set container component where the selection of tabs is displayed with Arrow  symbol.
    New features that sp4 provides is 1)Waterfall chart 2)Alerts are  supported for spreadsheet tables, and for
    combination charts.
    @Sri

  • Change mouse pointer for Assessment Simulation

    Hi there-
    I have an assessment simulation - and I need the users mouse
    pointer to change to a crosshair (I think that's what it's called)
    when the mouse is over a certain area on the screen. Is there
    anyway to do this? I know it can be done in a demonstration for the
    pointer in the demo.
    Lynn

    Authorware allows access to the system's mouse 'library', but
    it also
    allows full Windows File System access too...which could have
    security
    issues. So it's certainly possible...but, agreed, who knows
    whether such
    functionality would be integrated into CP.
    Erik
    CatBandit wrote:
    > Can't be done, Lynn, but what a great idea for a new
    feature!!
    >
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=15&6213=9.[/
    > b]
    >
    > The way I see it, you could select the mouse-pointer
    you want displayed on the
    > user's machine from the mouse-properties dialog. But
    wait! Now that I' said
    > that, it occurs to me that any security program worth a
    hoot might
    > automatically block this, as it requires access to
    Windows system files . . .
    >
    > Well, it's still worth requesting, and I think the
    developers could figure a
    > way around the security problems if there are any. Have
    a great day!
    > .
    >
    Erik Lord
    http://www.capemedia.net
    Adobe Community Expert - Authorware
    http://www.adobe.com/communities/experts/
    http://www.awaretips.net -
    samples, tips, products, faqs, and links!
    *Search the A'ware newsgroup archives*
    http://groups.google.com/group/macromedia.authorware

  • Change Mouse Pointer Look

    Hi,
    I have a show/hide layers behavior setup on an image - when
    the image is clicked. It works just fine. However, when you hover
    the mouse over the image, the mouse pointer doesn't change to the
    hand, like it would with a link. Is there any way to get the mouse
    pointer to change to the hand when it is hovering over the image?
    Thanks,
    Lynn

    Open the page in DW. Select the image and look at the
    behaviors panel.
    Change the Event from onClick to <A> onClick, using the
    drop-down list of
    events in the behaviors panel.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "L Gamble" <[email protected]> wrote in
    message
    news:e7hifj$6r6$[email protected]..
    > Hi,
    >
    > I have a show/hide layers behavior setup on an image -
    when the image is
    > clicked. It works just fine. However, when you hover the
    mouse over the
    > image, the mouse pointer doesn't change to the hand,
    like it would with a
    > link.
    > Is there any way to get the mouse pointer to change to
    the hand when it is
    > hovering over the image?
    >
    > Thanks,
    > Lynn
    >

  • Can you change the color of selected text in word?

    I use Word 2010, and when I select text it is always blue, is there a way to change the color?

    I use Word 2010, and when I select text it is always blue, is there a way to change the color?
    My earlier posting was an error.
    I apologize.
    You seem to be saying that the default colour for text is blue.
    You need to change:-
    Normal.dotm
     - to change the default colour of text.
    In order to change the default colour of text take the following steps (that were tested on Windows 7 and Office 2007 - the process should be
    similar, if not identical, for yourself):-
    1. Open a new blank document (this should
    have the default text as blue).
    Save that document with a new name for example:-
    c:\word\testing_aug_25_2014_2
    2. In the above document:-
    Insert tab
    Text group
    Click on the drop down arrow to the lower right of:-
    Quick Parts
     - then click on:-
    Field . . .
    The:-
    Field
     - window should open.
    3. In the:-
    Field
     - window in the field called:-
    Field names:
     - scroll down to:-
    Template
     - and click on that option so that it's highlighted in blue.
    Now, towards the top right hand corner of the same window, click in the box called:-
    Add path to file name
     - so that it has a tick (check mark) in that box.
    Click:-
    OK
    The file name of the template should now be inserted into your document.
    On my machine this was:-
    C:\Users\user_name\AppData\Roaming\Microsoft\Templates\Normal.dotm
    The above path might be different for you.
    4. I saved my document at this point.
    5. Now open the file called:-
    C:\Users\user_name\AppData\Roaming\Microsoft\Templates\Normal.dotm
    A document should open on your screen (still with blue text) and with:-
    Normal.dotm
    - in the middle of the Title Bar at the top of the screen.
    Highlight all of the text in the document so that it's (for example) black.
    Save the file.
    6. Close all open documents in WORD and
    close WORD itself.
    7. Now open a new document and its default
    text should be set to the colour that you applied at step 5. above (I used black at that point).
    Does that resolve your problem?

  • [JS, CS3] Need help changing tabStop positions of selected text

    Hi all,
    I am writing a script to nudge the tabStop positions of selected text by one point at a time. Sometimes it will be only a tab character selected, and other times it could be several in the paragraph or maybe even the whole story. The problem I am encountering is that when I reference the tabStops as app.selection[0].tabStops it includes ALL the tabStops in the paragraph and NOT just the selected ones. Is there a way to get just the selected tabStops and add a point to their positions? It must be that my referencing is flawed. Thanks for any help.
    Regards,
    Len Swierski

    Hi Len,
    That's not a bad approach, but remember that there may be more tab characters than there are tab stops. I was thinking of getting the location of the selected tab stop relative to the left edge of the text frame (or column, if you're working with multi-column frames) and then comparing it to the location of the tab stop. But I think your approach will work just as well and be quicker.
    Also, remember that when you start moving tab stops around, the index of the tab stop within the tab stops collection can change. If you have tab stop A at 12pt and tab stop B at 16pt, then tab stop A will be item(0) and B will be item (1). But if you move A to 24pt, A will become item(1) and B will be item(0). The index of the tab stop is relative to its location on the tab ruler.
    Thanks,
    Ole

  • Mouse pointer over links

    My mouse pointer changes to the hand for only a fraction of a second when it moves over a link and then changes back to the standard pointer icon. How do I fix this?
    I'm using Safari 1.3.2, OS X 10.3.9

    I'm not sure I understand the problem/question.... it's normal that mouse pointers turn into hands when passing through links, no matter what browser you use. And each time you move it turns into hand/pointer again and again... sometimes it even takes time until it turns back to pointer again, because he is "thinking"...
    Kisses
    CV

  • How to change mouse pointer

    I would like enlarge or change the color of the mouse pointer.  Can anyone help

    No, they didn't. I am running 10.7.3.

  • Changing mouse pointer

    I would like to be able to change my mouse pointer to something
    other that what set_application_property cursor_style can do for
    me. I would like to be able to call a mouse pointer from the
    file system and replace the the pointer in my forms app.
    Thanks in advance for any direction that can be given.
    Roland

    If your Mouse cursor is in a DLL you can do:
    Set_Application_Property(CURSOR_STYLE,'<DLLNAME>cursorname');
    For this to work you have to load the above DLL first using
    ORA_FFI.LOAD_LIBRARY().

  • ComboBox Problem to change the size of selected text in JTextPane.

    hi 2 all!
    I have a problem in combo box actions, when i change the item in the combo its set is not set at that time but that action is performed when next action is taken, i have used combobox.setAction(new StyledEditorKit.FontSizeAction(" click", 12);) command to set the size of the selected text
    Plz suggest the solution also if possible,plz provide some code for this
    Action action1 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 12);
                                       Action action2 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 14);
                                       Action action3 = new StyledEditorKit.FontSizeAction(
                                                 "double click", 18);
    s2 = (String) cb7.getSelectedItem();
                                       if (s2.equals("Small")) {
                                            cb7.setAction(action1);
                                            e1.setSource(cb7);
                                                      } else
                                       if (s2.equals("Medium")) {
                                            cb7.setAction(action2);
                                            e1.setSource(cb7);
                                                                          } else if (s2.equals("Large")) {
                                            cb7.setAction(action3);
                                            // e1.setSource(cb7);
    when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
    PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.
    thanx in advance..

    this code is not working properly according to the action i set on comboBox.Thats correct, the setAction() method is used to invoke an existing Action on the combo box, not create a new Action.
    What you need to do is have a single action that uses the information from the item that was selected to build a dynamic Action to change the font. Something like:
    public void actionPerformed(ActionEvent e)
         JComboBox comboBox = (JComboBox)e.getSource();
         int fontSize = Integer.parseInt( comboBox.getSelectedItem().toString() );
         Action fontAction = new StyledEditorKit.FontSizeAction("size", fontSize);
         fontAction.actionPerformed(null);
    }

  • How to underline the text when the mouse is over the text

    I want to underline text when I move a mouse over it? Is this possible with JavaFX event listener?

    Create some text, set style-class and add it to the scene.
    Text text = new Text("Hello World!");
    text.getStyleClass().add("text");
    In a stylesheet (e.g., my_styles.css file)
    .text:hover { -fx-underline: true; }
    Add the stylesheet to the scene:
    scene.getStylesheets().add("my_styles.css");
    Or, add a listener to the hoverProperty.
            text.hoverProperty().addListener(new ChangeListener<Boolean>() {
                @Override
                public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldVal, Boolean newVal) {
                        text.setUnderline(newVal);
    Or bind the underlineProperty to the hoverProperty
        text.underlineProperty().bind(text.hoverProperty());

  • 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

Maybe you are looking for

  • Working with Custom SQL Using Descriptor Query Manager Queries

    Hi All, I am Working on Descriptor Query Manager Queries Configuring Custom SQL Using Java and Workbench Using Java I wrote a static method as in the code given below. public static void insertEmployee(ClassDescriptor descriptor){ descriptor.getQuery

  • Can Mainstage 2 drive Apple Keynote, or other video/slides?

    Greetings fellow Keynoticians... I've used Keynote for years in concert, and am looking to upgrade to '09. I'm also a Logic 8 newbie, and am looking to upgrade to 9, mainly for Mainstage 2. I'm a one-man band. Years ago I used to have a full-blown MI

  • Convertion into kgs from other weight units

    Hi Experts, I need to convert material net_weight (NTGEW) into " KGs " from other units(GEWEI) (Whatever user enters like G, Pounds. etc..) and map to target field in db. Any UDFDo needful. Regards, Ramesh.

  • How2 load xml into datagrid, and create realtime search of datagrid data

    I wanted to be able to load xml data into a datagrid and then create a searchbox that would search in real time (as person typed) from any part of the datagrid.  Does anyone know of any as2.0 component that can do that easily?  If not, i would like t

  • 3d printer

    For study, we need to make a 3D-Printer and run it with labview, but if I load a STL file. I don't see a picture of it. I have search for turtorials but it seems there are not much tutorials how to work with 3 pictures in labview. A second problem is