Get the values entered in a TextField

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. 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. Thank you so much Tarek, that’s kind :) !!!
      0