I'm porting my code to the new b20 / Property release and run into this:
1. I have 42 ToggleButtons
2. To each I register the same ChangeListener (instead of 42 separate)
3. Inside the ChangeListener I want to find out which toggle button was the origin of the event
class {
private void x() {
ToggleButton lToggleButton = new ToggleButton();
lToggleButton.selectedModel().addChangeListener(iDayToggleButtonSelectedValueModelListener);
}
private ValueModelListener iDayToggleButtonSelectedValueModelListener = new ValueModelListener() {
@Override
public void handle(ObservableValue observableValue) {
BooleanProperty lBooleanProperty = (BooleanProperty)observableValue;
}
}
My problems are:
- I have to cast the ObservableValue to BooleanProperty to be able to access the value, that can't be right?!
- There is no way I can find what ToggleButton was clicked?
I would expect the addChangeListener to be generic;
...addChangeListener(ValueModelListener<BooleanProperty> ...)
I would expect the ValueModelListener use its generics:
public void handle(BooleanProperty observableValue)
1. I have 42 ToggleButtons
2. To each I register the same ChangeListener (instead of 42 separate)
3. Inside the ChangeListener I want to find out which toggle button was the origin of the event
class {
private void x() {
ToggleButton lToggleButton = new ToggleButton();
lToggleButton.selectedModel().addChangeListener(iDayToggleButtonSelectedValueModelListener);
}
private ValueModelListener iDayToggleButtonSelectedValueModelListener = new ValueModelListener() {
@Override
public void handle(ObservableValue observableValue) {
BooleanProperty lBooleanProperty = (BooleanProperty)observableValue;
}
}
My problems are:
- I have to cast the ObservableValue to BooleanProperty to be able to access the value, that can't be right?!
- There is no way I can find what ToggleButton was clicked?
I would expect the addChangeListener to be generic;
...addChangeListener(ValueModelListener<BooleanProperty> ...)
I would expect the ValueModelListener use its generics:
public void handle(BooleanProperty observableValue)
- is blocked by
-
JDK-8101341 Reorganize Property hierarchy
-
- Resolved
-