javafx - change achorpane effect after closing another screen -
i have fxml file called principale.fxml contain buton. when click on stage opened , boxblur effect added anchorpane in principale.fxml. iwant set effect null anchorpane when close second stage here code:
principale.fxml
info.addeventhandler(mouseevent.mouse_clicked, new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { parent home_page_p = fxmlloader.load(getclass().getresource("/view/information.fxml")); scene home_page_s = new scene (home_page_p); javafx.scene.effect.boxblur bxb = new boxblur(); ancr.seteffect(bxb); stage stage = new stage(); stage.initstyle(stagestyle.undecorated); stage.setscene(home_page_s); stage.show(); } catch (ioexception ex) { logger.getlogger(principalecontroller.class.getname()).log(level.severe, null, ex); }
when execute http://i.stack.imgur.com/vafqg.jpg
information.fxml
public void closeapp(mouseevent mv) throws ioexception { app_stage = (stage) close.getscene().getwindow(); app_stage.hide(); principalecontroller pc = new principalecontroller(); pc.ancr.seteffect(null); }
http://i.stack.imgur.com/vafqg.jpg
so when close information window want set principale.fxml effect null, should add closeapp method?
there multiple issues code. shouldn't type
controller ctl = new controller();
rather fetch fxmlloader using
fxmlloader loader = fxmlloader.load(getclass().getresource("/view/information.fxml")); parent home_page_p = loader.load(); controller ctl = loader.getcontroller();
later use create new stage :
stage stage = new stage(); stage.initstyle(stagestyle.undecorated); ctl.glisse(home_page_p, stage, home_page_s); stage.setscene(home_page_s); // adding event handler fired on event of stage being closed stage.setoncloserequest((windowevent event) -> { // perform action when stage closed ancr.seteffect(null); // ancr reference anchorpane }
note : don't need create instance of principalecontroller
because of above code written inside principalecontroller class
.