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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -