Search in sources :

Example 1 with TextComponent

use of java.awt.TextComponent in project jmeter by apache.

the class NumberFieldErrorListener method focusLost.

@Override
public void focusLost(FocusEvent e) {
    Component source = (Component) e.getSource();
    String text = "";
    if (source instanceof JTextComponent) {
        text = ((JTextComponent) source).getText();
    } else if (source instanceof TextComponent) {
        text = ((TextComponent) source).getText();
    }
    try {
        Integer.parseInt(text);
    } catch (NumberFormatException nfe) {
        JOptionPane.showMessageDialog(source, //$NON-NLS-1$
        JMeterUtils.getResString("you_must_enter_a_valid_number"), //$NON-NLS-1$
        JMeterUtils.getResString("invalid_data"), JOptionPane.WARNING_MESSAGE);
        FocusRequester.requestFocus(source);
    }
}
Also used : TextComponent(java.awt.TextComponent) JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent) TextComponent(java.awt.TextComponent) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Aggregations

Component (java.awt.Component)1 TextComponent (java.awt.TextComponent)1 JTextComponent (javax.swing.text.JTextComponent)1