Roughian Examples Site Map - GWT Examples - Tutorials

Button


Version 1.0 onwards

You click it, something happens



Listeners



Notes


It's just a button. For it to do anything, you need to add a listener. And you probably want some text. There are a number of ways to do this. The code shown here is the most compact but least flexible. It is also (depending on where in the coding world you come from) probably not the easiest to get your head around. For more examples, please see the ClickListener entry in the GWT Listeners menu.


Code


class Demo extends Composite implements ClickListener
{
    public Demo()
    {
        initWidget(new Button("Demo", this));
    }
    public void onClick(Widget sender)
    {
        Window.alert("Click Event Fired");
    }
}