Problems with multiple click on a button

Yes and it works. Thanks! I was complicating things. I saw that myButton.setDisableOnClick(true) was mentioned but didn’t try that. Thanks again.

I tested this solution. Seems to work against double-clicks:
(note: I have a table containing list of records. A button is embedded in each table line for editing the record - clicking it will open a modal edition dialog - fast clicking caused multiple modals to open on the same record)


private LocalDateTime lastRecordTableClick= LocalDateTime.now();

private void OnClickEditRow(ClickEvent event) 
{
    // Prevent fast click causing the opening of multiple modal for editing detail of selected record
    // one click per second ! no more !
    LocalDateTime now = LocalDateTime.now();
    long diffInMilli = java.time.Duration.between(lastRecordTableClick, now).toMillis();
    lastRecordTableClick=now; // remember last clic time      
    if(diffInMilli<1000) return;
    //-----------------------------------------------------

Although very late to the party just in case someone else finds this post, you can also setEnabled(false) when you start the process and then setEnabled(true) when you’re done. Just make sure that you also catch any error conditions and/or exceptions to re-enable the button if you need to.

How to make a button move page, just move page…
i am so confuse about that…
sorry iam is newbie developer with vaadin, so can you help me???

sorry i talk in english so poor…

Just in case if someone is still facing this issue, I fixed it by implementing custom click listeners and one of them is as follows:

public abstract class TRButtonClickListener implements Button.ClickListener, Serializable {

	private static final long serialVersionUID = 1L;

	private long sleepDuration = 250L;
	volatile boolean isFired = false;

	@Override
	public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
		if (!isFired) {
			synchronized (this) {
				if (!isFired) {
					isFired = true;
					try {
						onButtonClick(event);
					} finally {
						Executors.newSingleThreadExecutor().execute(() -> {
							try {
								Thread.sleep(sleepDuration);
							} catch (InterruptedException e) {
							} finally {
								isFired = false;
							}
						});
					}
				}
			}
		}
	}

	public TRButtonClickListener withSleepDuration(long sleepDuration) {
		this.sleepDuration = sleepDuration;
		return this;
	}

	public abstract void onButtonClick(com.vaadin.ui.Button.ClickEvent event);
}

and using it as follows:

Button button = new Button("Click Me!", new TRButtonClickListener() {
	@Override
	public void onButtonClick(ClickEvent event) {
		System.out.println("This will get fired only once.");
	}
});