How can i put line numbers in JTextArea (like we have in general editors like WordPad or EditPlus etc...)??? N.
posted 14 years ago
Hi, nice idea, but I think, you can't put your line numbers inside the JTestArea. The JTextArea displays a String and it breaks the lines short before the right end of the area appears. If you want to display your line numbers inside the area, you need to modify the string. This is not so good. So you need a different component to display the numbers. And you have to calculate the number of lines. I did this in a printing api which was able to print text (There I also had to calculate, how many lines will fit on one page and how many pages I will have) I did this with the LineBreakMeasurer. Please have a look to the API to see examples how it works. Hope this helps