javaFX: a custom control(made with scene builder) contain a buttom with an onAction -
javafx: custom control(made scene builder) contain buttom onaction(and other components). how can implement method when use controll in screen ?
you can provide callback can implemented. example:
public class mycontrol { private button button; private callback<void, void> buttoncallback; public mycontrol() { button.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent event) { if(getbuttoncallback() != null){ getbuttoncallback().call(null); } } }); } public callback<void, void> getbuttoncallback() { return buttoncallback; } public void setbuttoncallback(callback<void, void> buttoncallback) { this.buttoncallback = buttoncallback; } }
now can provide different implementations of callback using setter.
Comments
Post a Comment