use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class CheckboxDemoPage method addCheckboxLazyHtmlLabel.
private void addCheckboxLazyHtmlLabel() {
Checkbox checkbox = new Checkbox();
checkbox.setId("lazy-html-label-checkbox");
NativeButton button = new NativeButton("Set label", event -> {
checkbox.setLabelAsHtml("Accept the <a href='https://vaadin.com/privacy-policy'>privacy policy</a>");
});
button.setId("set-html-label");
addCard("Checkbox with the lazy label that contains HTML markup", checkbox, button);
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class CheckboxPage method createInitialValueTest.
// https://github.com/vaadin/vaadin-checkbox-flow/issues/22
private Component createInitialValueTest(boolean checked, boolean indeterminate) {
int id = checked ? 1 : 0;
id += indeterminate ? 2 : 0;
Checkbox checkbox2 = new Checkbox("initial value cb");
checkbox2.setValue(checked);
checkbox2.setIndeterminate(indeterminate);
checkbox2.setId("cb-" + id);
Label valueLabel = new Label("Value: " + checkbox2.getValue());
valueLabel.setId("value-label-" + id);
Label indeterminateLabel = new Label("Indeterminate: " + checkbox2.isIndeterminate());
indeterminateLabel.setId("indeterminate-label-" + id);
AtomicInteger checkedCounter = new AtomicInteger();
checkbox2.addValueChangeListener(event -> {
valueLabel.setText("Value: " + checkedCounter.incrementAndGet() + " " + event.getValue());
});
AtomicInteger indeterminateCounter = new AtomicInteger();
checkbox2.getElement().addPropertyChangeListener("indeterminate", event -> indeterminateLabel.setText("Indeterminate: " + indeterminateCounter.incrementAndGet() + " " + event.getValue()));
return new Div(checkbox2, valueLabel, indeterminateLabel);
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class CheckboxUnitTest method initialValue.
@Test
public void initialValue() {
Checkbox checkbox = new Checkbox();
Assert.assertFalse(checkbox.getValue());
checkbox = new Checkbox(true);
Assert.assertTrue(checkbox.getValue());
checkbox = new Checkbox(false);
Assert.assertFalse(checkbox.getValue());
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class CheckboxUnitTest method setEnable.
@Test
public void setEnable() {
Checkbox checkbox = new Checkbox("foo", true);
checkbox.setEnabled(true);
Assert.assertTrue(checkbox.isEnabled());
checkbox.setEnabled(false);
Assert.assertFalse(checkbox.isEnabled());
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class HasLabelTest method checkbox.
@Test
public void checkbox() {
Checkbox c = new Checkbox();
Assert.assertTrue(c instanceof HasLabel);
}
Aggregations