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 JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea" Watch "JTextArea" New topic
Author

JTextArea

Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
If I create a JTextArea, and type something, then how do I copy the text into another JTextArea?

Also, how do I save the text in the JTextArea into a text file?


amerzil co-ed student<br />"Praise be the Code"
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
textArea2.setText(textArea1.getText());

for file reading/writing
http://java.sun.com/docs/books/tutorial/essential/io/
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Hi, Karabao

Welcome to JavaRanch! Please adjust your display name to meet the JavaRanch Naming Policy.
You can change it here.

Thanks!


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Do you mean you want the second text area to reflect at all times what's in the original text area? You can install a javax.swing.event.DocumentListener on the first text area's document to do that. Again, you just have to copy the text value of the first into the second as Michael Dunn showed before.


James Carman, President<br />Carman Consulting, Inc.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Moving to our Swing forum...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea
 
Similar Threads
JDialog Dilemma I Have
Insertion in JTextArea
Setting alignment in JTextArea
Using JScrollPane
superscript text JTextArea