I recently did something like this.  The approach I took was to add a
JTextPane to a JPanel with a wide left margin and then override the paint()
method in the JPanel to draw the line numbers in the margin using
Graphics.drawString().  You can then add the panel to a JScrollPane to get a
scrolling text pane with line numbers.

Brett

> -----Original Message-----
> From: Panagiotis Plevrakis [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 01, 2002 5:32 PM
> To: JDJList
> Subject: [jdjlist] Line numbers
> 
> 
> I'm trying to implement visible line numbers in a code 
> editor. I don't want 
> the numbers to be part of the code. So, my first approach is 
> to create a 
> JTextArea to the left of the main editor area that will 
> listen to the text 
> length changes and display the appropriate sequence of line 
> numbers. If 
> someone has done something similar or has any ideas to give 
> me, I would 
> appreciate it.
> 
> Panos
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to