Answer the question
In order to leave comments, you need to log in
How to call a variable (which is sealed in public void) after the code from the question description - JavaFX?
Hello. There is a code below. I need to call newValue variable from this code after this code. How to do it? If I call this variable after this code, then it writes an error newValue cannot be resolved to a variable.
// Adding Listener to value property.
slider.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, //
Number oldValue, Number newValue) {
infoLabel.setText("Вы выбрали: " + Math.round(newValue.floatValue()));
}
});
Answer the question
In order to leave comments, you need to log in
Declare a global variable at the beginning of the
Number globalValue class declaration;
and inside the changed function, fill it in:
globalValue = newValue;
Then use globalValue
Above you were answered with a crutch for which your hands are torn off. Get your value from slider.getValue()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question