I'm working on a simple java IDE for personal use, but I'm having trouble when it comes to displaying line numbes for the file you're editing.
Here's how the IDE I currently use displays line numbers:
And here's a screen of the IDE i'm writing:
I can't seem to figure out how I'm going to go about displaying the line numbers next to my JTextArea. When I was designing my IDE, the plan was to subclass a JPanel, and simply draw the line numbers in the area to the left of the textarea displaying, and then offset the y when you scroll the textarea. However, I am worried that my line numbers will get offset, because I don't think that the row height in JTextArea's are consistant across operating systems.
One other option that I considered was to use another JTextArea to display the line numbers. That way, the rows for both of the JTextArea's will line up. When I scroll the textarea containing the code, the textarea containing the line numbers would scroll accordingly. However, I don't want to see a scrollbar next to the line numbers. If I set the scrollbar's visibility to false, will the textarea still reserve room for it, and can I still scroll the textarea up and down?