Results 1 to 6 of 6
  1. #1
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Color line in JTextArea after a mouse clik

    Hello,
    I want color and retrieve the contents of each row selected by the mouse in JTextArea.
    the problem that I can not do it with a single clik but it works with double clik.
    Java Code:
    if (evt.getClickCount()== 2)
     
    {
    TextArea.setSelectionColor(Color.BLUE);
    String a = TextArea.getSelectedText();
    System.out.println(a);
    }
    when I put
    Java Code:
    if (evt.getClickCount()== 1)
    The coloring does not work anymore and the result of display always null

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Color line in JTextArea after a mouse clik

    If you want help, you should provide an SSCCE that demonstrates exactly what's going on.

    Without the SSCCE I'm just guessing, but it would seem that a single click deselects any text, and a double click selects the word you clicked on. That seems like pretty normal behavior, so if you want something else to happen, you'll have to program it.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Color line in JTextArea after a mouse clik

    thanks for your request but it's possible to select the word by one clik

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Color line in JTextArea after a mouse clik

    Quote Originally Posted by Ridha View Post
    thanks for your request but it's possible to select the word by one clik
    Like I said, without an SSCCE, I'm only guessing.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Ridha is offline Member
    Join Date
    Jan 2013
    Posts
    28
    Rep Power
    0

    Default Re: Color line in JTextArea after a mouse clik

    really i did'n understand what is the SSCCE , i use netbeans to develop management application not website

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Color line in JTextArea after a mouse clik

    I linked to a site explaining what an SSCCE is. It's the standard way to post code when asking for help on a forum. Here it is again: Short, Self Contained, Correct Example
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Different text color in JTextArea
    By bigvanilla in forum New To Java
    Replies: 2
    Last Post: 01-29-2011, 02:21 PM
  2. Mouse Click changes Color of Rectangle
    By DocIcarus in forum New To Java
    Replies: 1
    Last Post: 11-23-2010, 01:53 PM
  3. change color on mouse click
    By hannerz06 in forum New To Java
    Replies: 3
    Last Post: 03-31-2010, 09:46 PM
  4. change object color on mouse click
    By gotenks05 in forum Java Applets
    Replies: 1
    Last Post: 04-05-2009, 07:14 PM
  5. Replies: 1
    Last Post: 05-19-2007, 12:03 PM

Posting Permissions

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