java - JavaFX getting buttons from controller to another class -
i have uicontroller class , buttonmethods class. buttonmethods class contains code button actions. need able use buttons controller class in buttonmethods class. example, have these defined in controller class
buttonmethods button = new buttonmethods(); @fxml button buttonlockdown; @fxml button buttonrelease;
and example, buttonlockdown has actionevent when clicked
@fxml private void actionlockdown(actionevent event) { button.lockdown();
ideally, want buttonmethods this:
public void lockdown() { buttonlockdown.setdisable(true); onlockdown = true; buttonrelease.setdisable(false);
i can't put code action event various reasons, , putting button objects parameters messy i'm trying do. how can fxml objects button class?
try send uicontroller parameter:
private uicontroller thiscontroller; @override public void initialize(url url, resourcebundle rb) { thiscontroller = this; } @fxml private void actionlockdown(actionevent event) { button.lockdown(thiscontroller);
then
public void lockdown(uicontroller controller) { controller.getbuttonlockdown().setdisable(true); onlockdown = true; controller.getbuttonrelease().setdisable(false);
you can use bindings in appropriate situations.
Comments
Post a Comment