Serializable
, CellEditor
, TableCellEditor
, TreeCellEditor
public class NumberEditorExt extends DefaultCellEditor
DefaultCellEditor.EditorDelegate
changeEvent, listenerList
clickCountToStart, delegate, editorComponent
Constructor | 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 | Description |
---|---|---|
Number |
getCellEditorValue() |
|
JFormattedTextField |
getComponent() |
|
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() |
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
addCellEditorListener, removeCellEditorListener
cancelCellEditing, getClickCountToStart, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell
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
Copyright © 2018. All rights reserved.