Search code examples
javaswingawtjtextarea

Delete particular string in JTextarea


I have developing application with AWT, and I use JTextarea for displaying some string values, values are retrieving from database. In this i want delete particular string in JTextarea, I have tried a lot,but i cant.Plz Give me the suggestion. My code

for (Entry<String, String> entry : checkList.entrySet()) {
                            String client_Name=entry.getKey();
                            if(!liHashMap.containsKey(client_Name))
                            {
                             checkList.remove(client_Name);
                            taNames.setText("");//But It removes all values
                       //here i want to remove the particular client_Name from 
                            JTextarea.
                            }
                         }  

Solution

  • Try

    taNames.setText( taNames.getText.replaceAll( client_Name, "" ) )