jeudi 11 juin 2020

create if statement in each text area line to see if it is null or not

In my code right now a string is added each time the user hits enter. What I want to do is have the text only be added to the line if the line is not empty. IF the line is empty I just want the line to remain blank. To show you what I am looking for I added a gif.

  public void keyPressed(KeyEvent e) {
   if(e.getKeyCode() == KeyEvent.VK_ENTER){

       text11.jt.setText(text11.jt.getText() + "     sam");


   }
}

enter image description here

Aucun commentaire:

Enregistrer un commentaire