Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

step through text in JTextArea

 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to step through the text in JTextArea.
I can display text from a file using JFileChooser, and I can save the contents of text in JTextArea to a file.

I need to know hot to step trhough the text in JtextArea. Please any pointer, code sample will be greatly appreciated.

Thanks.

Anu
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
step through - what are the 'steps'?

the textArea just contains a String so you can create whetever steps you want.
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response.
I can get text in textarea by following line of code

String taContains = myTextArea.getText();

taContains string contains text with new lines.

I want to hilight certain line when mouse os on that line in the TextArea. How to achieve this? Thanks

Anu
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I want to hilight certain line when mouse os on that line in the TextArea.

by mouse on that line, if you mean the caret i.e. click the line, the line is highlighted
something like this perhaps, or look up the Highlighter class

(easier to show it, than try to explain it)
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved from Java in General
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Moved from Java in General

my only chance of winning a book - gone :-)
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone has developed a small Java file for this purpose already, making it really easy. Have a look
(Please note that I haven't tried it)

http://tips4java.wordpress.com/2008/10/29/line-painter/
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

Thanks much. This is exactly what I wanted to do.

Regards,

Anu Bhagat




Michael Dunn wrote:> I want to hilight certain line when mouse os on that line in the TextArea.

by mouse on that line, if you mean the caret i.e. click the line, the line is highlighted
something like this perhaps, or look up the Highlighter class

(easier to show it, than try to explain it)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic