How to pass number to TextField JavaFX?

后端 未结 3 759
独厮守ぢ
独厮守ぢ 2021-01-23 18:20

I am working on simple calculator, where users input two numbers in TextField and the result is displayed in result TextField. I used Double.pars

3条回答
  •  甜味超标
    2021-01-23 19:07

    There is no method TextField.setText (double)

    try

    resultInput.setText("" + resultV);
    

    but I guess what you really want is for the result to be nicely formatted to maybe two decimal places?

    try using

    resultInput.setText(String.format ("%6.2f", resultV));
    

提交回复
热议问题