0

I have created a simple calculator in java using net beans. In this calculator when user accidentally press dot button(jButton) multiple time textfield shows many dots as user pressed. for example if user press dot button after five three times it appears like 5... so I need to set a jTextField to accept only one dot when input user press dot button. dot can't be pressed more than once. How can I do this?

Arkam
  • 1
  • 1
  • Before appending the dot, check if the string already has a dot? – k_ssb Jun 19 '18 at 13:34
  • The classic answer would be to use a flag, or a boolean variable to show when the button has been pressed. If the button is pressed, set the flag to false, so that when they try to press it again, check the flag with an if and if the flag is false, then you don't accept the decimal – cjnash Jun 19 '18 at 13:34
  • Thanks for your help it is really helped me – Arkam Jun 19 '18 at 15:15

0 Answers0