public class NumberEditorExt extends DefaultCellEditor
DefaultCellEditor.EditorDelegate
Modifier and Type | Field and Description |
---|---|
private static Class<?>[] |
argTypes |
(package private) Constructor<?> |
constructor |
private boolean |
useStrictFormatter |
clickCountToStart, delegate, editorComponent
changeEvent, listenerList
Constructor and Description |
---|
NumberEditorExt()
Instantiates an editor with default NumberFormat and default NumberFormatter.
|
NumberEditorExt(boolean useStrictFormatter)
Instantiates an editor with default NumberFormat and NumberFormatter depending
on useStrictFormatter.
|
NumberEditorExt(NumberFormat format)
Instantiates an editor with the given NumberFormat and default NumberFormatter.
|
NumberEditorExt(NumberFormat format,
boolean useStrictFormatter)
Instantiates an editor with the given NumberFormat and NumberFormatter depending on
useStrictFormatter.
|
Modifier and Type | Method and Description |
---|---|
private static JFormattedTextField |
createFormattedTextField(NumberFormat formatter)
Creates and returns a JFormattedTextField configured with defaults.
|
private static JFormattedTextField |
createFormattedTextFieldX(NumberFormat format)
Creates and returns a JFormattedTextField configured with SwingX extended
NumberFormat and StrictNumberFormatter.
|
Number |
getCellEditorValue()
Overridden to instantiate a Number of the expected type.
|
JFormattedTextField |
getComponent()
Convenience override with type cast.
|
protected Number |
getNumber()
Returns the editor value as number.
|
Component |
getTableCellEditorComponent(JTable table,
Object value,
boolean isSelected,
int row,
int column)
Override and set the border back to normal in case there was an error previously
|
protected boolean |
hasStrictFormatter() |
protected boolean |
isValid()
Returns a boolean indicating whether the current text is valid for
instantiating the expected Number type.
|
boolean |
stopCellEditing() |
cancelCellEditing, getClickCountToStart, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addCellEditorListener, removeCellEditorListener
Constructor<?> constructor
private boolean useStrictFormatter
public NumberEditorExt()
public NumberEditorExt(NumberFormat format)
format
- the NumberFormat to use for conversion, may be null to indicate
usage of default NumberFormat.public NumberEditorExt(boolean useStrictFormatter)
useStrictFormatter
- if true, uses a StrictNumberFormatter, else uses
default NumberFormatterpublic NumberEditorExt(NumberFormat format, boolean useStrictFormatter)
format
- the NumberFormat to use for conversion, may be null to indicate
usage of default NumberFormatuseStrictFormatter
- if true, uses a StrictNumberFormatter, else uses
default NumberFormatterpublic boolean stopCellEditing()
stopCellEditing
in interface CellEditor
stopCellEditing
in class DefaultCellEditor
protected boolean isValid()
protected Number getNumber() throws Exception
Exception
- if creation of the expected type fails in some way.protected boolean hasStrictFormatter()
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
getTableCellEditorComponent
in interface TableCellEditor
getTableCellEditorComponent
in class DefaultCellEditor
public Number getCellEditorValue() throws IllegalStateException
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.
getCellEditorValue
in interface CellEditor
getCellEditorValue
in class DefaultCellEditor
IllegalStateException
- if current value invalidpublic JFormattedTextField getComponent()
Convenience override with type cast.
getComponent
in class DefaultCellEditor
private static JFormattedTextField createFormattedTextFieldX(NumberFormat format)
private static JFormattedTextField createFormattedTextField(NumberFormat formatter)
Use a static method so that we can do some stuff before calling the superclass.
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses