1. Revert jTextField to last good value stackoverflow.comI have an |
2. temporarily disable ok button on a JDialog, accordingly to a JTextField validation stackoverflow.comI have a JDialog created in a fashion like this, accordingly to Oracle's tutorial. using the JOptionPane constructor:
|
3. JTextField InputVerifier coderanch.compublic boolean verifyInputJawad(String content){ boolean returnValue = true; if (content.length() != 0) { try { Double.parseDouble(content); Double value = new Double(content); if(value.doubleValue() <= 0){ JOptionPane.showConfirmDialog(this, "Please enter a number greater than 0", "Enter Number", JOptionPane.CLOSED_OPTION); returnValue = false; } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "Please enter a number greater than 0"); System.out.println("Please Enter a valid number"); returnValue = false; } ... |