public class ConfigState extends Object
The intention is that restoring from state encoded in this object
should be lenient, for instance ignoring unrecognised keys,
so that it can be used in contexts in which the format has changed
somewhat between serialization and deserialization, for instance
as a consequence of sofware updates.
The various restore(key,component)
methods will not affect the
supplied GUI components in the case that the map contains no entry
for the given key.
Constructor and Description |
---|
ConfigState()
Constructs an empty state object.
|
ConfigState(Map<String,String> map)
Constructs an object populated by a given map.
|
Modifier and Type | Method and Description |
---|---|
int |
getInt(String key)
Retrieves an entry of this map as an integer.
|
Map<String,String> |
getMap()
Returns the map on which this object is based.
|
void |
restoreFlag(String key,
ButtonModel model)
Restores the selection state of a toggle button model from this map.
|
void |
restoreSelection(String key,
JComboBox<?> selector)
Restores the selection of a combo box from this map.
|
void |
restoreText(String key,
JTextComponent textComp)
Restores the text content of a text component from this map.
|
void |
saveFlag(String key,
ButtonModel model)
Stores the selection state of a button model in this map.
|
void |
saveSelection(String key,
JComboBox<?> selector)
Stores the selection of a combo box in this map.
|
void |
saveText(String key,
JTextComponent textComp)
Stores the text content of a text component in this map.
|
void |
setInt(String key,
int value)
Sets an entry of this map as an integer.
|
public Map<String,String> getMap()
public void setInt(String key, int value)
key
- entry keyvalue
- integer valuepublic int getInt(String key)
key
- entry keypublic void saveFlag(String key, ButtonModel model)
key
- entry keymodel
- toggle model containing statepublic void restoreFlag(String key, ButtonModel model)
key
- entry keymodel
- toggle model to be updated with statepublic void saveText(String key, JTextComponent textComp)
key
- entry keytextComp
- component containing statepublic void restoreText(String key, JTextComponent textComp)
key
- entry keytextComp
- text component to be updated with statepublic void saveSelection(String key, JComboBox<?> selector)
key
- entry keyselector
- selection component containing stateCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.