[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Obtaining line & column in JEditorPane

Posted on 2005-04-07
5
Medium Priority
?
385 Views
Last Modified: 2012-05-05
I want to write an editor using JEditorPane. I know how to obtain caret position. But I would like to obtain current line & column where the caret is. Is there some simple method to do this, without  keeping and updating "by hand" a table of begins of lines?
0
Comment
Question by:rainette
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1000 total points
ID: 13730642
0
 

Author Comment

by:rainette
ID: 13743460
To objects: thank you, but the article in your link doesn't respond to my problem. I don't want to add line number to every line displayed. Instead I want to track a caret movement and "translate" its position into line/column displayed in "status line".
To do this I could build a table od lines beginnings and search it everytime when the caret position changes. But  in a case of "true" editing action, i.e. inserting or deleting I have to rebuild that table i.e. to rescan  the whole document. For example I have to do it after every character typing. And my problem is: how could I do this "translation" without superfluous waste of time ?
0
 
LVL 92

Expert Comment

by:objects
ID: 13745232
There is no simple way that I'm aware of, shouldn't the link I posted above help based on it needs to determine the line number to display it?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question