private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int i = 0;
        int numPalabras = 0;
        String texto = textArea.getText();
        texto += " ";

        if(texto.length() > 0) {
            do {

                if(texto.charAt(i) != ' ' && texto.charAt(i+1) == ' ') {
                    numPalabras++;
                }
                i++;
            } while(i < texto.length() - 1);
            campoPalabras.setText(String.valueOf(numPalabras));
       }

    }//GEN-LAST:event_jButton1ActionPerformed