List of usage examples for javax.swing JTextField getText
public String getText()
TextComponent
. From source file:Main.java
/** * Get int from the JTextField input//from w w w . j av a 2 s . co m * * @param input the JTextField object * @return the int number */ public static int getInt(javax.swing.JTextField input) throws Exception { return new Integer(input.getText()).intValue(); }
From source file:Main.java
/** * Get double from the JTextField input//from w ww. j a v a 2 s . c o m * * @param input the JTextField object * @return the double number */ public static double getDouble(javax.swing.JTextField input) throws Exception { return new Double(input.getText()).doubleValue(); }
From source file:BusinessLogic.java
public static int getValue(JTextField tf) { try {//from w ww .ja va 2 s . c o m return Integer.parseInt(tf.getText()); } catch (NumberFormatException e) { return 0; } }
From source file:Main.java
/** * Check if the JTextField input is larger or equal than x * /* w w w . j a va 2 s. com*/ * @param input the JTextField object * @param x parameter x * @return true or false */ public static boolean largeEqualThan(javax.swing.JTextField input, double x) throws Exception { double d = new Double(input.getText()).doubleValue(); if (d >= x) return true; return false; }
From source file:Main.java
/** * Select all text in a {@link JComponent} if it is a {@link JTextField} or {@link JTextArea}. * * @param comp the component//from ww w.j ava2 s . c om */ public static void selectAllText(JComponent comp) { if (comp instanceof JTextField) { JTextField tf = (JTextField) comp; tf.setSelectionStart(0); tf.setSelectionEnd(tf.getText().length()); } else if (comp instanceof JTextArea) { JTextArea ta = (JTextArea) comp; ta.setSelectionStart(0); ta.setSelectionEnd(ta.getText().length()); } }
From source file:br.com.pontocontrol.controleponto.util.SwingUtils.java
public static LocalTime getLocalTimeValueFromField(JTextField field) { String value = field.getText(); if (StringUtils.isNotBlank(value)) { try {/* w w w . j a v a 2 s.c o m*/ return LocalTime.from(LOCAL_TIME_FORMATTER.parse(value)); } catch (DateTimeParseException e) { } } return null; }
From source file:br.com.pontocontrol.controleponto.util.SwingUtils.java
public static Date getDateValueFromField(JTextField field) { String value = field.getText(); if (StringUtils.isNotBlank(value)) { try {// w w w . java 2s .c o m return getDateValueFromField(SIMPLE_DATE_FORMATTER_A, field); } catch (ParseException e) { } } return null; }
From source file:de.codesourcery.eve.skills.ui.components.AbstractEditorComponent.java
protected static boolean isBlank(JTextField textField) { return StringUtils.isBlank(textField.getText()); }
From source file:br.com.pontocontrol.controleponto.util.SwingUtils.java
public static void validateField(SimpleDateFormat formatter, JTextField field) throws ParseException { String valor = field.getText(); if (StringUtils.isNotBlank(valor)) { Date date = formatter.parse(valor); field.setText(formatter.format(date)); }//from ww w .j av a 2 s. c om }
From source file:br.com.pontocontrol.controleponto.util.SwingUtils.java
public static Date getDateValueFromField(SimpleDateFormat formatter, JTextField field) throws ParseException { String value = field.getText(); if (StringUtils.isNotBlank(value)) { return formatter.parse(value); }/*from w w w . j a v a 2 s . c om*/ return null; }