alexandra84

Untitled

Nov 22nd, 2018
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /**
  2. * Called this when the user clicks on the save button or finish to fill the text field.
  3. */
  4. private void handleSave() {
  5. // If the inputs are valid we save the data
  6. if(isInputValid()){
  7. note=(DOUBLE.parseDouble(textField.getText()));
  8. }else // do something such as notify the user and empty the field
  9. }
  10.  
  11. /**
  12. * Validates the user input in the text fields.
  13. *
  14. * @return true if the input is valid
  15. */
  16. private boolean isInputValid() {
  17. Boolean b= false;
  18. if (!(textField.getText() == null || textFiled.getText().length() == 0)) {
  19. try {
  20. // Do all the validation you need here such as
  21. Double d = Double.parseInt(textFiled.getText());
  22. if ( 1.0<d<6.0){
  23. b=true;
  24. }
  25. } catch (NumberFormatException e) {
  26. }
  27. return b;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment