• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clear JTextArea

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone suggest a method to clear the text in the JTextArea?
Puja
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 1492
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MyTextArea.setText("") worked perfectly for me.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Probably worked equally well for Puja, 11 years ago.
 
Pedro Neves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic