Code example for NumberFormat

Methods: parse

0
 
    @Override 
    public void focusGained(FocusEvent event) {
        JTextField origen = (JTextField) event.getComponent();
        try { 
            origen.setText(String.valueOf(currencyFormatter.parse(origen.getText())));
        } catch (ParseException ex) {
            origen.setText("");
        } 
    } 
 
    @Override 
    public void focusLost(FocusEvent event) {
        JTextField origen = (JTextField) event.getComponent();
        double monto = InputUtils.parseDouble(origen.getText());
        if (monto == 0) {
            origen.setText("");
        } else { 
            origen.setText(currencyFormatter.format(monto));
        } 
    }