List of usage examples for javax.swing JTextField select
public void select(int selectionStart, int selectionEnd)
From source file:com.osparking.osparking.Settings_System.java
/** * Checks if natural number is entered and give warning when non-numeric entered. * @param textField field whose text is supposed to contain a number * @param dialogTitle title of the dialog box that will be shown when non-natural number string is entered * @return <b>true</b> when a natural number is in the <code>textField</code>, * <b>false</b> otherwise/*from ww w. ja v a2s.c om*/ */ private boolean TextFieldNumericValueOK(JTextField textField, String dialogTitle) { // Check if empty string or numeric 0 were entered. String input = textField.getText().trim(); input = removeNonNumeric(input); if (input.length() == 0 || Integer.parseInt(input) == 0) { JOptionPane.showConfirmDialog(this, "Enter a value of 1 or more ..", dialogTitle, JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE); textField.requestFocusInWindow(); textField.select(0, input.length()); return false; } else { return true; } }