/** * Lets the user know that the text they entered is bad. Returns true if the user elects to revert * to the last good value. Otherwise, returns false, indicating that the user wants to continue * editing. */ protected boolean userSaysRevert() { Toolkit.getDefaultToolkit().beep(); ftf.selectAll(); Object[] options = {"Editar", "Revertir"}; String mensaje = "El valor debe ser "; if (minimum != null && maximum != null) mensaje += "mayor a " + minimum + " y menor a " + maximum; else { if (minimum != null) mensaje += "mayor a " + minimum; if (maximum != null) mensaje += "menor a " + maximum; } int answer = JOptionPane.showOptionDialog( SwingUtilities.getWindowAncestor(ftf), mensaje + ".\n" + "¿Deseas editar el número " + "o revertir los cambios?", "Valor ingresado no válido", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[1]); if (answer == 1) { // Revert! ftf.setValue(ftf.getValue()); return true; } return false; }