File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes step through text in JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "step through text in JTextArea" Watch "step through text in JTextArea" New topic
Author

step through text in JTextArea

Anu Bhagat
Ranch Hand

Joined: Jun 20, 2008
Posts: 64
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


SCJP5.0, SCJA
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
step through - what are the 'steps'?

the textArea just contains a String so you can create whetever steps you want.
Anu Bhagat
Ranch Hand

Joined: Jun 20, 2008
Posts: 64
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: May 03, 2008
Posts: 4523
    
    5

Moved from Java in General


luck, db
There are no new questions, but there may be new answers.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Moved from Java in General

my only chance of winning a book - gone :-)
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 497

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/


Are you better than me? Then please show me my mistakes..
Anu Bhagat
Ranch Hand

Joined: Jun 20, 2008
Posts: 64
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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: step through text in JTextArea
 
Similar Threads
JDialog Dilemma I Have
JTextArea
mutilple color text in Jtextarea or JTextPane
how to get the info from a jtextarea
how to get the info from a jtextarea