@Override public Object getCellEditorValue() { try { getComponent().commitEdit(); return getComponent().getValue(); } catch (ParseException ex) { return null; } } };
@Override public void setValue(Object value) { getComponent().setValue(value); }
@Override public Object getCellEditorValue() { try { getComponent().commitEdit(); return getComponent().getValue(); } catch (ParseException ex) { return null; } } };
@Override public Object getCellEditorValue() { try { getComponent().commitEdit(); return getComponent().getValue(); } catch (ParseException ex) { return null; } } };
@Override public Object getCellEditorValue() { try { getComponent().commitEdit(); return getComponent().getValue(); } catch (ParseException ex) { return null; } } };
@Override public void setValue(Object value) { getComponent().setValue(value); }
@Override public void setValue(Object value) { getComponent().setValue(value); }
@Override public void setValue(Object value) { getComponent().setValue(value); }
@Override public void setValue(Object value) { ((JFormattedTextField)getComponent()).setValue(value); }
@Override public Object getCellEditorValue() { JFormattedTextField textField = ((JFormattedTextField)getComponent()); try { textField.commitEdit(); return textField.getValue(); } catch (ParseException ex) { return null; } } };
/** Override and set the border back to normal in case there was an error previously */ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { ((JComponent)getComponent()).setBorder(new LineBorder(Color.black)); try { final Class type = table.getColumnClass(column); // Assume that the Number object we are dealing with has a constructor which takes // a single string parameter. if (!Number.class.isAssignableFrom(type)) { throw new IllegalStateException("NumberEditor can only handle subclasses of java.lang.Number"); } constructor = type.getConstructor(argTypes); } catch (Exception ex) { throw new IllegalStateException("Number subclass must have a constructor which takes a string", ex); } return super.getTableCellEditorComponent(table, value, isSelected, row, column); }
/** * {@inheritDoc} <p> * * Overridden to instantiate a Number of the expected type. Note that this * may throw a IllegalStateException if invoked without querying * for a valid value with stopCellEditing. This should not happen during * normal usage. * * @throws IllegalStateException if current value invalid * */ @Override public Number getCellEditorValue() throws IllegalStateException { try { return getNumber(); } catch (Exception ex) { throw new IllegalStateException("Number conversion not possible from " + "current string " + getComponent().getText()); } }
/** * {@inheritDoc} <p> * * Overridden to instantiate a Number of the expected type. Note that this * may throw a IllegalStateException if invoked without querying * for a valid value with stopCellEditing. This should not happen during * normal usage. * * @throws IllegalStateException if current value invalid * */ @Override public Number getCellEditorValue() throws IllegalStateException { try { return getNumber(); } catch (Exception ex) { throw new IllegalStateException("Number conversion not possible from " + "current string " + getComponent().getText()); } }
/** * {@inheritDoc} <p> * * Overridden to instantiate a Number of the expected type. Note that this * may throw a IllegalStateException if invoked without querying * for a valid value with stopCellEditing. This should not happen during * normal usage. * * @throws IllegalStateException if current value invalid * */ @Override public Number getCellEditorValue() throws IllegalStateException { try { return getNumber(); } catch (Exception ex) { throw new IllegalStateException("Number conversion not possible from " + "current string " + getComponent().getText()); } }
/** * {@inheritDoc} <p> * * Overridden to instantiate a Number of the expected type. Note that this * may throw a IllegalStateException if invoked without querying * for a valid value with stopCellEditing. This should not happen during * normal usage. * * @throws IllegalStateException if current value invalid * */ @Override public Number getCellEditorValue() throws IllegalStateException { try { return getNumber(); } catch (Exception ex) { throw new IllegalStateException("Number conversion not possible from " + "current string " + getComponent().getText()); } }
/** Override and set the border back to normal in case there was an error previously */ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { ((JComponent)getComponent()).setBorder(new LineBorder(Color.black)); try { final Class<?> type = table.getColumnClass(column); if (hasStrictFormatter()) { // delegate to formatter which decides at parsing time // then either handles or throws ((NumberFormatter) getComponent().getFormatter()).setValueClass(type); } else { // Assume that the Number object we are dealing with has a constructor which takes // a single string parameter. if (!Number.class.isAssignableFrom(type)) { throw new IllegalStateException("NumberEditor can only handle subclasses of java.lang.Number"); } constructor = type.getConstructor(argTypes); } // JW: in strict mode this may fail in setting the value in the formatter return super.getTableCellEditorComponent(table, value, isSelected, row, column); } catch (Exception ex) { // PENDING JW: super generic editor swallows all failures and returns null // should we do so as well? throw new IllegalStateException("value/type not compatible with Number", ex); } }
/** * Returns a boolean indicating whether the current text is valid for * instantiating the expected Number type. * * @return true if text is valid, false otherwise. */ protected boolean isValid() { if (!getComponent().isEditValid()) return false; try { if (!hasStrictFormatter()) getNumber(); return true; } catch (Exception ex) { } return false; }
/** * Returns a boolean indicating whether the current text is valid for * instantiating the expected Number type. * * @return true if text is valid, false otherwise. */ protected boolean isValid() { if (!getComponent().isEditValid()) return false; try { if (!hasStrictFormatter()) getNumber(); return true; } catch (Exception ex) { } return false; }
/** * Returns a boolean indicating whether the current text is valid for * instantiating the expected Number type. * * @return true if text is valid, false otherwise. */ protected boolean isValid() { if (!getComponent().isEditValid()) return false; try { if (!hasStrictFormatter()) getNumber(); return true; } catch (Exception ex) { } return false; }
/** * Returns a boolean indicating whether the current text is valid for * instantiating the expected Number type. * * @return true if text is valid, false otherwise. */ protected boolean isValid() { if (!getComponent().isEditValid()) return false; try { if (!hasStrictFormatter()) getNumber(); return true; } catch (Exception ex) { } return false; }