Module org.controlsfx.controls
Class SpreadsheetCellEditor
java.lang.Object
org.controlsfx.control.spreadsheet.SpreadsheetCellEditor
- Direct Known Subclasses:
SpreadsheetCellEditor.DateEditor
,SpreadsheetCellEditor.DoubleEditor
,SpreadsheetCellEditor.IntegerEditor
,SpreadsheetCellEditor.ListEditor
,SpreadsheetCellEditor.ObjectEditor
,SpreadsheetCellEditor.StringEditor
,SpreadsheetCellEditor.TextAreaEditor
SpreadsheetCellEditor are used by
If the user does anything outside the editor, the editor will be forced to try to commit the edition and close itself. If the value is not valid, the editor will cancel the value and close itself. The editor is just here to allow communication between the user and the
You can abandon a current modification by pressing "esc" key.
You can specify a maximum height to your spreadsheetCellEditor with
You just have to override the four abstract methods. Remember that you will never call those methods directly. They will be called by the
Keep in mind that you will interact only with

SpreadsheetCellType
and
SpreadsheetCell
in order to control how each value will be entered. General behavior:
Editors will be displayed if the user double-click in an editable cell ( seeSpreadsheetCell.setEditable(boolean)
). If the user does anything outside the editor, the editor will be forced to try to commit the edition and close itself. If the value is not valid, the editor will cancel the value and close itself. The editor is just here to allow communication between the user and the
SpreadsheetView
.
It will just be given a value, and it will just give back another one after.
The policy regarding validation of a given value is defined in
SpreadsheetCellType.match(Object)
.
If the value doesn't meet the requirements when saving the cell, nothing
happens and the editor keeps editing. You can abandon a current modification by pressing "esc" key.
You can specify a maximum height to your spreadsheetCellEditor with
getMaxHeight()
. This can be used in order to control the display of your editor. If they
should grow or not in a big cell. (for example a SpreadsheetCellEditor.TextAreaEditor
want
to grow with the cell in order to take full space for display.
Specific behavior:
This class offers some static classes in order to create aSpreadsheetCellEditor
. Here are their properties: -
SpreadsheetCellEditor.StringEditor
: BasicTextField
, can accept all data and save it as a string. -
SpreadsheetCellEditor.ListEditor
: Display aComboBox
with the different values. -
SpreadsheetCellEditor.DoubleEditor
: Display aTextField
which accepts only double value. If the entered value is incorrect, the background will turn red so that the user will know in advance if the data will be saved or not. -
SpreadsheetCellEditor.IntegerEditor
: Display aTextField
which accepts only Integer value. If the entered value is incorrect, the background will turn red so that the user will know in advance if the data will be saved or not. -
SpreadsheetCellEditor.DateEditor
: Display aDatePicker
. -
SpreadsheetCellEditor.ObjectEditor
: Display aTextField
, accept an Object.
Creating your editor:
You can of course create your ownSpreadsheetCellEditor
for displaying other controls.You just have to override the four abstract methods. Remember that you will never call those methods directly. They will be called by the
SpreadsheetView
when needed.
-
startEdit(Object)
: You will configure your control with the given value which isSpreadsheetCell.getItem()
converted to an object. You do not instantiate your control here, you do it in the constructor. -
getEditor()
: You will return which control you're using (for display). -
getControlValue()
: You will return the value inside your editor in order to submit it for validation. -
end()
: When editing is finished, you can properly close your own control.
Keep in mind that you will interact only with
endEdit(boolean)
where
a true value means you want to commit, and a false means you
want to cancel. The SpreadsheetView
will handle all the rest for you
and call your methods at the right moment. Use case :

Visual:
String | ![]() |
List | ![]() |
Double | ![]() |
Date | ![]() |
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ASpreadsheetCellEditor
forSpreadsheetCellType.DateType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.DoubleType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.DoubleType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.ListType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.ObjectType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.StringType
typed cells.static class
ASpreadsheetCellEditor
forSpreadsheetCellType.StringType
typed cells. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct the SpreadsheetCellEditor. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
end()
This method will be called at the end of edition.
You will be offered the possibility to do the configuration post editing.final void
endEdit
(boolean b) Whenever you want to stop the edition, you call that method.
True means you're trying to commit the value, thenSpreadsheetCellType.convertValue(Object)
will be called in order to verify that the value is correct.
False means you're trying to cancel the value and it will be follow byend()
.
See SpreadsheetCellEditor descriptionabstract String
Return the value within your editor as a string.abstract javafx.scene.control.Control
Return the control used for controlling the input.double
Return the maximum height of the editor.void
This method will be called when edition start.
You will then do all the configuration of your editor.abstract void
Does the same asstartEdit(java.lang.Object)
but you have also theSpreadsheetCell.getFormat()
sent.
-
Constructor Details
-
SpreadsheetCellEditor
Construct the SpreadsheetCellEditor.- Parameters:
view
-
-
-
Method Details
-
endEdit
public final void endEdit(boolean b) Whenever you want to stop the edition, you call that method.
True means you're trying to commit the value, thenSpreadsheetCellType.convertValue(Object)
will be called in order to verify that the value is correct.
False means you're trying to cancel the value and it will be follow byend()
.
See SpreadsheetCellEditor description- Parameters:
b
- true means commit, false means cancel
-
startEdit
This method will be called when edition start.
You will then do all the configuration of your editor.- Parameters:
item
-
-
startEdit
Does the same asstartEdit(java.lang.Object)
but you have also theSpreadsheetCell.getFormat()
sent. This is useful when editing Date for example, when you want to display it with the cell format. Also options given by a Spreadsheetcell withSpreadsheetCell.getOptionsForEditor()
are given.- Parameters:
item
-format
-options
-
-
getEditor
public abstract javafx.scene.control.Control getEditor()Return the control used for controlling the input. This is called at the beginning in order to display your control in the cell.- Returns:
- the control used.
-
getControlValue
Return the value within your editor as a string. This will be used by theSpreadsheetCellType.convertValue(Object)
in order to compute whether the value is valid regarding theSpreadsheetCellType
policy.- Returns:
- the value within your editor as a string.
-
end
public abstract void end()This method will be called at the end of edition.
You will be offered the possibility to do the configuration post editing. -
getMaxHeight
public double getMaxHeight()Return the maximum height of the editor.- Returns:
- 50 by default.
-