List of utility methods to do JTextField Value Get
double | getDouble(javax.swing.JTextField input) Get double from the JTextField input return new Double(input.getText()).doubleValue(); |
double | getDoubleFromTextField(JTextField textField, double defaultValue) get Double From Text Field double value = defaultValue; try { value = Double.parseDouble(textField.getText()); } catch (NumberFormatException nfe) { textField.setText(defaultValue + ""); return value; |
double | getDoubleTextField(javax.swing.JTextField textField) Return the text field value as a double. return Double.parseDouble(textField.getText().trim());
|
String | getFieldValue(JTextField tf) get Field Value String ret = tf.getText().trim(); if (!ret.equals("")) { return ret; return null; |
int | getInt(javax.swing.JTextField input) Get int from the JTextField input return new Integer(input.getText()).intValue(); |
int | getInt(JTextField tf) get Int return Integer.parseInt(tf.getText());
|
Integer | getInteger(JTextField txt, Integer defaultVal) get Integer String str = txt.getText(); if (str.trim().length() <= 0) return defaultVal; int val = 0; try { val = Integer.parseInt(str); } catch (NumberFormatException ex) { return new Integer(val); |
int | getIntegerFromTextField(JTextField tf, int previousValue) Gets the integer from text field. if (tf.getText().length() > 0) { try { int num = Integer.parseInt(tf.getText()); tf.setForeground(Color.black); return num; } catch (NumberFormatException ex) { tf.setForeground(Color.red); return previousValue; |
int | getIntValue(JTextField component) get Int Value return Integer.parseInt(component.getText());
|
String | getLabelText(JTextField textField) get Label Text Container container = textField.getParent(); for (Component component : container.getComponents()) { if (component instanceof JLabel) { JLabel label = (JLabel) component; if (label.getLabelFor() == textField) { return label.getText(); return null; |