I want to update the value on the JavaFx textfield after an event. I have a RootScreen which opens a popup and in that popup i have a listview . When a user select the item on that listview, it should update the value on the texfield in RootScreen .
This is the code for the action on the button which is present on every list item. Every listItem also has a TEXTFIELD and button to select it. I want the value on the TEXTFIELD to be on the texfield in RootScreen.Kindly see the uppercase and lowercase as i tried to make it as understandable as possible.
public void initialize() {
button.setOnAction(event -> {
source = select.getParent();
//walletname is the name i want on textfield.
walletName = textField.getText();
getWalletName(walletName);
Stage stage = (Stage) source.getScene().getWindow();
stage.close();
});
}
private void getWalletName(String walletName){
profilePopup.SetText(walletName,rootScreenController);
}
The SetText method is in the Popup View Class. The code for SetText method.
public void SetText(String walletName, OnClick onClick){
onClick.onMouseClicked(walletName);
}
I have a interface OnClick, which has a onMouseClicked method . The interface i implemented in RootScreen
public interface OnClick {
void onMouseClicked(String name);
}
This is how I am overriding the method in the interface.
@Override
public void onMouseClicked(String walletName) {
textfield.setText(walletname);
}
But its not updating the value on the textfield. I am new in java, so I am not sure what to do here.