How to implement GWT, Java, button, and the clickhandler -
forgive me if question has been asked , answered, have been unable find if has.
i can find several examples like
button.addclickhandler(new clickhandler() { public void onclick(clickevent event) { ... stuff ... } });
i'm trying understand how implement button click handler using following structure.
public class myclass implements entrypoint { final button mybutton = new button("text"); : : void onclickmybutton(???) { ... stuff ... } : : }
to "me", structure more read , preference in coding style. don't know how implement it.
i'm using eclipse , gwt java web app. appreciated.
either
public class myclass implements entrypoint, clickhandler { final button mybutton = new button("text"); : : mybutton.addclickhandler(this); @override void onclick(clickevent event) { ... stuff ... } }
or
public class myclass implements entrypoint { final button mybutton = new button("text"); : : mybutton.addclickhandler(new clickhandler() { public void onclick(clickevent event) { onclickmybutton(event); } }); private void onclickmybutton(clickevent event) { ... stuff ... } }
the second 1 cleaner, , allows handling several buttons separate methods.
Comments
Post a Comment