/** Constructs cell editor. */
    public CellEditor() {
      super(new JFormattedTextField());
      final JFormattedTextField ftf = (JFormattedTextField) getComponent();

      // Set GUI behaviour of text field
      ftf.setValue(null);
      ftf.setHorizontalAlignment(JTextField.LEADING);
      ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

      // Set that one click on cell is enough for editing
      setClickCountToStart(1);

      // Special handling code for ENTER
      ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
      ftf.getActionMap()
          .put(
              "check",
              new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                  if (!ftf.isEditValid()) {
                    if (askEditOrRevert(ftf, null)) {
                      ftf.setValue(ftf.getValue());
                      ftf.postActionEvent();
                    }
                  } else
                    try {
                      ftf.commitEdit();
                      ftf.postActionEvent();
                    } catch (java.text.ParseException exc) {
                      // nothing to do
                    }
                }
              });
    }