Results 1 to 4 of 4
  1. #1
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default Get Row/Column In JEditorPane

    Is it possible to get the row and column when you click on a spot in the JEditorPane. My current thought is to get the position of the click event and do a few calculations based on the row height and column width but I wanted to know if there is an existing way that is less likely to incur errors.

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    JEditorPane extends JTextComponent which has a nifty method viewToModel(Point pt). You should check out the API for more on this method and give it a try. Please let us know if it doesn't work.

  3. #3
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    Works like a charm. I never realized this was the function I was looking for when I was browsing the API. Thanks for the help.

    You'd figure this would be a 'get*' method.

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    I don't think it's a getXXX method because you're not really getting a property of the view but in fact are trying to get something much more complex, to use a point on the view to get information from the model.

    You're welcome.

Similar Threads

  1. insert row and column and delete row and column
    By daredavil82 in forum New To Java
    Replies: 13
    Last Post: 09-22-2011, 07:10 PM
  2. JEditorPane + MouseWheel
    By Moncleared in forum New To Java
    Replies: 2
    Last Post: 10-09-2010, 02:27 AM
  3. Replies: 1
    Last Post: 07-06-2010, 05:50 PM
  4. JEditorPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 08:47 PM
  5. JEditorPane
    By drmmr11 in forum Java Applets
    Replies: 0
    Last Post: 08-02-2007, 07:08 PM

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
  •