summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/tests/book/TheButtons.java
blob: e5a22457eef6bb8ac01f7c0ef406008d9acb8700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.itmill.toolkit.tests.book;

import com.itmill.toolkit.ui.AbstractComponentContainer;
import com.itmill.toolkit.ui.Button;

public class TheButtons implements Button.ClickListener {
    Button thebutton;
    Button secondbutton;

    /** Creates two buttons into given container. */
    public TheButtons(AbstractComponentContainer container) {
        thebutton = new Button("Do not push this button");
        thebutton.addListener(this);
        container.addComponent(thebutton);

        secondbutton = new Button("I am a button too");
        secondbutton.addListener(this);
        container.addComponent(secondbutton);
    }

    /** Handle button click events from the two buttons. */
    public void buttonClick(Button.ClickEvent event) {
        if (event.getButton() == thebutton) {
            thebutton.setCaption("Do not push this button again");
        } else if (event.getButton() == secondbutton) {
            secondbutton.setCaption("I am not a number");
        }
    }
}