All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.vaadin.elements.CheckboxWithError Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.vaadin.elements;

import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.checkbox.CheckboxGroup;

import java.util.Set;

public class CheckboxWithError extends CheckboxGroup
{
	private final String label;
	public CheckboxWithError(String label)
	{
		this.label = label;
		setItems(Set.of(label));
		setItemLabelGenerator(x -> "");
		addValueChangeListener(e -> setInvalid(false));
		add(new Html("
" + label + "
")); setClassName("check-box-with-error"); } public boolean getState() { return getValue().contains(label); } public void setValue(boolean value) { if(value) setValue(Set.of(label)); else deselect(label); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy