public class StringEditor extends PropertyEditorSupport
JTextField
. It turns into editing mode, when
a key is pressed. While in editing mode all attempts to setAsText(String)
or
setValue(Object)
are blocked.
Typing ENTER turns of editing, updates the
value to the edited String
, and informs PropertyChangeListener
s.
When ESC is pressed or focus is lost the editing is canceled, i.e.
the old value is restored and editing mode is turned off.
The user gets feedback about the current editing mode via the background color. The
colors are taken from editingBackground
and displayingBackground
Modifier and Type | Field and Description |
---|---|
static Color |
displayingBackground |
static Color |
editingBackground |
Constructor and Description |
---|
StringEditor() |
Modifier and Type | Method and Description |
---|---|
String |
getAsText() |
Component |
getCustomEditor() |
boolean |
isEditing() |
void |
setAsText(String text) |
void |
setValue(Object value) |
boolean |
supportsCustomEditor() |
addPropertyChangeListener, firePropertyChange, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource
public static Color displayingBackground
public static Color editingBackground
public String getAsText()
getAsText
in interface PropertyEditor
getAsText
in class PropertyEditorSupport
public Component getCustomEditor()
getCustomEditor
in interface PropertyEditor
getCustomEditor
in class PropertyEditorSupport
public boolean isEditing()
public void setAsText(String text)
setAsText
in interface PropertyEditor
setAsText
in class PropertyEditorSupport
public void setValue(Object value)
setValue
in interface PropertyEditor
setValue
in class PropertyEditorSupport
public boolean supportsCustomEditor()
supportsCustomEditor
in interface PropertyEditor
supportsCustomEditor
in class PropertyEditorSupport