Effiecient method to get number of lines in a JEditorPane

My Computer Science class has a major grade project to complete by Dec. 15. For my project I've decided to make a tabbed Java IDE with save, open, compile, run, and some font options. Due to the need to make Java use the command prompt to compile and run, it will be Windows specific.

Now, next to my JEditorPane I want to put a JPanel with a GridLayout full of JLabels that will hold the line numbers. I'm having a small problem getting the precise number of lines though. Due to the nature of JEditorPane, I can't just count the number of newline characters in the JEditorPane. I've tried to use a Scanner to go through the text and find all instances of the string "<p style=\"margin-top: 0\">" but because the JEditorPane doesn't make a new

tag until text is entered into a new line, this only works some of the time.

Does anyone know of a way I can effectively and efficiently find the number of lines in the JEditorPane at any given time?

Message was edited by:

TheGuy@YourWindow

[1032 byte] By [bronze-starDukes] at [2007-11-26 12:13:27]
# 1

Swing related questions should be posted in the Swing forum.

Normally for a text editor you would use a JTextArea for simple text or a JTextPane if you plan on doing syntax highlighting. JEditorPane is typically used to display HTML files.

If you search the Swing forum using "utextcomponent" you will find my class that has methods that might be handy for what you want.

platinumsta at 2007-7-7 14:14:47 > top of Java-index,Archived Forums,Socket Programming...