Results 1 to 2 of 2
  1. #1
    Problemer is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default JTextPane , MouseListener on certain words.

    Hello,

    I have an jTextPane wich displays search results from a database. I Would like to make certain words active to a MouseListener , i have done some searches but i am afraid that it is only possible to make the whole JTextPane do the same thing with MouseListener.

    Would it be possible to have certain words do certain things?

    Best Regards
    Rickard

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    357
    Rep Power
    5

    Default Re: JTextPane , MouseListener on certain words.

    There's probably better ways to do it, but one option would be to add the MouseListener to your JTextPane as you said, and inside of your mouseReleased() method, call getSelectedText() on the JTextPane, and if the returned value is the String you are interested in, perform your action.

Similar Threads

  1. Help with mouselistener
    By kastraki2000 in forum Java Applets
    Replies: 2
    Last Post: 04-30-2011, 04:56 PM
  2. can't get x and y from mouselistener
    By j2me64 in forum Java 2D
    Replies: 3
    Last Post: 04-24-2010, 05:57 PM
  3. MouseListener & GUI
    By Suurisa in forum New To Java
    Replies: 2
    Last Post: 10-27-2009, 01:52 AM
  4. i need help for MouseListener
    By sfaxianovic in forum New To Java
    Replies: 2
    Last Post: 08-21-2008, 04:30 AM
  5. MouseListener
    By Aswq in forum New To Java
    Replies: 12
    Last Post: 07-18-2008, 09:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •