Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Called this when the user clicks on the save button or finish to fill the text field.
- */
- private void handleSave() {
- // If the inputs are valid we save the data
- if(isInputValid()){
- note=(DOUBLE.parseDouble(textField.getText()));
- }else // do something such as notify the user and empty the field
- }
- /**
- * Validates the user input in the text fields.
- *
- * @return true if the input is valid
- */
- private boolean isInputValid() {
- Boolean b= false;
- if (!(textField.getText() == null || textFiled.getText().length() == 0)) {
- try {
- // Do all the validation you need here such as
- Double d = Double.parseInt(textFiled.getText());
- if ( 1.0<d<6.0){
- b=true;
- }
- } catch (NumberFormatException e) {
- }
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment