aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes clear 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 "clear JTextArea" Watch "clear JTextArea" New topic
Author

clear JTextArea

puja
Greenhorn

Joined: Jun 29, 2001
Posts: 1
Can anyone suggest a method to clear the text in the JTextArea?
Puja
T Pelly
Greenhorn

Joined: Jun 29, 2001
Posts: 5
Try using the method:
replaceRange(String str, int start, int end)
str = ""
start = 0
end = 'how ever many character you have'
There must be a cleaner way, but I'm not sure what it is!
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi puja,
How about something simple like:
setText("");
According to API:

Sets the text of this TextComponent to the specified text. If the text is null or empty, has the effect of simply deleting the old text.

Regards,
Manfred.
Pedro Neves
Ranch Hand

Joined: Mar 07, 2012
Posts: 64
MyTextArea.setText("") worked perfectly for me.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

Pedro Neves wrote:MyTextArea.setText("") worked perfectly for me.


Probably worked equally well for Puja, 11 years ago.


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

Joined: Mar 07, 2012
Posts: 64
Darryl Burke wrote:
Pedro Neves wrote:MyTextArea.setText("") worked perfectly for me.


Probably worked equally well for Puja, 11 years ago.



AHAHA.. oh god.. what a dumb ass.. sorry i really didn't noticed on the date of the post..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clear JTextArea