Directory

← Back

DelayedButton

Button that becomes active only after given delay.

Author

Rating

Popularity

<100

DelayedButton is a Button variant that becomes active only after a specified amount of time. This way the user cannot accidentally just click the button and ignore an important message on screen. Use DelayedButton for example to present license acceptance, demo version dialogs, or similar cases that require user to stop and think for a while. Displays a countdown counter in button caption.

While this might be a useful component, primarily this component is an example of a simple GWT based Vaadin add-on. Especially the project setup in GitHub demonstrates some useful thing:

  • Maven setup for a Vaadin add-on
  • Extending client-side Vaadin components
  • assembly.xml to do proper zip add-on packaging
  • Headless browser tests using Java
  • Automatic Travis CI configuration and badge in GutHub
  • Directory download badge in GutHub

Sample code

        // Delay for 5 seconds
        DelayedButton btn = new DelayedButton("Continue", 5,
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        getMainWindow().showNotification("Thank you for clicking.");
                    }
                });
        mainWindow.addComponent(btn);
package org.vaadin.delayedbutton;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;

public class DelayedButtonApplication extends Application {

    private static final long serialVersionUID = 1L;

    @Override
    public void init() {
        Window mainWindow = new Window("DelayedButton Sample Application");
        Label label = new Label("Please read this:\n"
                + "It is important that you see this.\n\n",
                Label.CONTENT_PREFORMATTED);
        mainWindow.addComponent(label);

        // Delay for 5 seconds
        DelayedButton btn = new DelayedButton("Continue", 5,
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        getMainWindow().showNotification("Ready");
                    }
                });

        // Delay for 5 seconds ( Disabled)
        DelayedButton btn2 = new DelayedButton("Continue", 5,
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        getMainWindow().showNotification("Ready");
                    }
                });
        btn2.setEnabled(false);


        mainWindow.addComponent(btn);
        mainWindow.addComponent(btn2);
        setMainWindow(mainWindow);
    }
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Updated dependencies.

Released
2022-01-24
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 8.0+
Vaadin 7.0+ in 2.0.1
Vaadin 6.2+ in 1.0.1
Browser
Browser Independent

DelayedButton - Vaadin Add-on Directory

Button that becomes active only after given delay. DelayedButton - Vaadin Add-on Directory
DelayedButton is a Button variant that becomes active only after a specified amount of time. This way the user cannot accidentally just click the button and ignore an important message on screen. Use DelayedButton for example to present license acceptance, demo version dialogs, or similar cases that require user to stop and think for a while. Displays a countdown counter in button caption. While this might be a useful component, primarily this component is an example of a simple GWT based Vaadin add-on. Especially the [project setup in GitHub](https://github.com/samie/delayedbutton) demonstrates some useful thing: * Maven setup for a Vaadin add-on * Extending client-side Vaadin components * assembly.xml to do proper zip add-on packaging * Headless browser tests using Java * Automatic Travis CI configuration and badge in GutHub * Directory download badge in GutHub
Online