Get the values entered in a TextField

Thinathenet Posted messages 23 Status Member -  
Thinathenet Posted messages 23 Status Member -
Hello,
I would like to know please, how can we retrieve the values entered in a TextField so that we can use them in other calculations???

1 answer

  1. tarek_dotzero Posted messages 834 Status Member 122
     
    Hello,

    The JTextField component contains a string; to retrieve it:

    String chaine = monTextField.getText();

    If you want to perform calculations, that is, if you want to treat it as an integer for example, then you need to convert it:

    int n = Integer.parseInt(chaine);

    Good luck.
    1
    1. Thinathenet Posted messages 23 Status Member 1
       
      Thank you so much Tarek, that’s kind :) !!!
      0