Results 1 to 3 of 3
  1. #1
    shivam0101 is offline Member
    Join Date
    Mar 2010
    Posts
    28
    Rep Power
    0

    Default Getting caret position from jtextarea

    This i posted in stackoverflow.com, still waiting for response.

    To get the row and column number i use,
    Java Code:
       int caretpos = textArea.getCaretPosition();
       int row = textArea.getLineOfOffset(caretpos);
    
       int column = caretpos - textArea.getLineStartOffset(row);
    If i know the row number and column number, how to get the caret position?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Getting caret position from jtextarea

    Moved from New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Getting caret position from jtextarea

    From where do you get the row number and column number? If you have a Point, you can use viewToModel(...)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 04-16-2010, 01:56 AM
  2. get position in string from caret position
    By helloworld111 in forum AWT / Swing
    Replies: 5
    Last Post: 02-19-2009, 01:36 AM
  3. Replies: 1
    Last Post: 10-13-2008, 12:42 PM
  4. Creating a caret in SWT
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-02-2008, 07:52 PM
  5. How to use TextLayout with Caret
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-25-2008, 10:36 AM

Tags for this Thread

Posting Permissions

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