java - addign a existing handler method with setOnAction -
i want assign existing handlemodellaction
method generated hyperlink setonaction
method, don't know how this.
here code example:-
@fxml private void handlemodellaction(actionevent event) throws ioexception{ fxmlloader load = new fxmlloader(getclass().getresource("inex.fxml")); parent root = (parent) load.load(); stage stage = new stage(); stage.setscene(new scene(root)); stage.show(); link = (hyperlink) event.gettarget(); model = link.getid(); stage.settitle(model); } public void addneuesmodell(string bauart, string modelname){ modelhyperlink = new hyperlink(); modelhyperlink.setid(modelname); modelhyperlink.settext(modelname); modelhyperlink.setonaction(#handlemodellaction); }
does know how this?
thanks lot :)
you try call setonaction
method on modelhyperlink
, pass parameter anonymous class handler, in transfer logic of handlemodellaction
method. below can find example:
hyperlink link = new hyperlink(); link.settext("http://example.com"); link.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent e) { fxmlloader load = new fxmlloader(getclass().getresource("inex.fxml")); parent root = (parent) load.load(); stage stage = new stage(); stage.setscene(new scene(root)); stage.show(); link = (hyperlink) event.gettarget(); model = link.getid(); stage.settitle(model); } });
Comments
Post a Comment