I want to show linenumbers left of my JTextArea but I have no (good)
idea how to implement it. :-/
Has anybody a (simple) solution for this "problem"?
kind regards
Markus
IchBin - 29 Nov 2005 16:19 GMT
> I want to show linenumbers left of my JTextArea but I have no (good)
> idea how to implement it. :-/
[quoted text clipped - 4 lines]
>
> Markus
Guess you cold just prefix a line, ala a loop, concat the prefix and
text line into the TextArea with insert(concat(loopIndex+" "+text,
loopIndex).
You may want to do some formatting on the index before the concat.
Or with out a look..
int lineNum = getRows();
insert(concat((lineNum+1)+" "+text, lineNum+1);

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin - 29 Nov 2005 16:36 GMT
> I want to show linenumbers left of my JTextArea but I have no (good)
> idea how to implement it. :-/
[quoted text clipped - 4 lines]
>
> Markus
Guess you could do something this..
String separator = " ";
inserRow = textArea.getRow( )+1;
textArea.insert( inserRow + seperator + lineData ), inserRow );
You may want to format the separator field to manage it's size to be
consistent.

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin - 29 Nov 2005 16:42 GMT
>> I want to show linenumbers left of my JTextArea but I have no (good)
>> idea how to implement it. :-/
[quoted text clipped - 13 lines]
> You may want to format the separator field to manage it's size to be
> consistent.
Sorry for two msg's. I am running SeaMonkey and it blows up now when I
send a response to the newsgroups.
Also
inserRow = textArea.getRow( )+1;
should be
inserRow = textArea.getRows( )+1;

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
oulan bator - 29 Nov 2005 16:56 GMT
you can build a Ruler object (that shows line number, based on line
height).
stick together in a panel, this ruler and the JTextArea, add this panel
into a JScrollPane.
1- Maybe you'll need a bit of hack to make the jscrollpane works well
(as in a JTable)
2- je row height can be retreived through the JTextArea font !
BR
Roedy Green - 29 Nov 2005 17:41 GMT
>I want to show linenumbers left of my JTextArea but I have no (good)
>idea how to implement it. :-/
>
>Has anybody a (simple) solution for this "problem"?
Use a JTable with a column for the numbers.
Use a Canvas and render the line number and text yourself as I do in
JDisplay to display Java listings on my website.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.