Imagine having an enum defining mouse-modes:
public enum MouseMode {
SELECTION,
EDITING,
DELETING }
And imagine having a toggle-group made of 3 buttons:
ToggleButton selection = new ToggleButton("Select");
ToggleButton editing = new ToggleButton("Edit");
ToggleButton deleting = new ToggleButton("Delete");
ToggleGroup mouseSelection = new ToggleGroup();
I want a field MouseMode currentMode
to be bidirectionally linked to the toggle-group. Whenever a toggle is set, currentMode is switched accordingly but also if some external process changes currentMode (maybe a key press) then the togglegroup adapts accordingly.
I can do this with 2 listeners but I wonder if there is a way to create a custom bidirectional map.