Winston Posted October 13, 2004 Share Posted October 13, 2004 As the title says it all, how's it possible to select a line so that's highlighted inside the JTextArea component thanks Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted October 13, 2004 Share Posted October 13, 2004 jta.setSelectionStart(beginning); jta.setSelectionEnd(end); where beginning is the index of the start of the line and end is the end of the line. Link to comment Share on other sites More sharing options...
0 John Veteran Posted October 13, 2004 Veteran Share Posted October 13, 2004 You can't highlight text in a textbox. You can select it though :p They're different things :whistle: [/perfectionist] Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted October 13, 2004 Share Posted October 13, 2004 It's highlighted when it's selected though ;) Link to comment Share on other sites More sharing options...
0 John Veteran Posted October 13, 2004 Veteran Share Posted October 13, 2004 Yes, but you can't highlight it without selecting it :p At least not without using a rich-edit textbox ;) Link to comment Share on other sites More sharing options...
0 Winston Posted October 14, 2004 Author Share Posted October 14, 2004 hmm ok... well i tried it and it isnt quite working,how come that method isnt documented in the API? btw thanks for helping. Link to comment Share on other sites More sharing options...
0 Winston Posted October 14, 2004 Author Share Posted October 14, 2004 ok well i got it working, how would i be able to determine how many chars is in a particular line because all i want to do is select/highlight a particular line for example: THIS IS LINE 1 THIS IS LINE 2 however i wouldn't know how many chars is in any of the lines, how would i go about highlighting say line 1 thanks :D Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted October 14, 2004 Share Posted October 14, 2004 jta.setSelectionStart(0); jta.setSelectionEnd(jta.getText().indexOf('\n')); Would select the first line. Link to comment Share on other sites More sharing options...
Question
Winston
As the title says it all, how's it possible to select a line so that's highlighted inside the JTextArea component
thanks
Link to comment
Share on other sites
7 answers to this question
Recommended Posts