Skip to content

Instantly share code, notes, and snippets.

@lofidewanto
Created November 5, 2020 22:41
Show Gist options
  • Save lofidewanto/f037fde3a7871cb01b50dc0864eb3a4d to your computer and use it in GitHub Desktop.
Save lofidewanto/f037fde3a7871cb01b50dc0864eb3a4d to your computer and use it in GitHub Desktop.
Component Domino Composite
package org.dominokit.samples;
import elemental2.dom.HTMLDivElement;
import org.dominokit.domino.ui.forms.CheckBox;
import org.dominokit.domino.ui.forms.TextBox;
import org.dominokit.domino.ui.grid.flex.FlexDirection;
import org.dominokit.domino.ui.grid.flex.FlexItem;
import org.dominokit.domino.ui.grid.flex.FlexLayout;
import org.dominokit.domino.ui.utils.BaseDominoElement;
public class OptionalTextBox extends BaseDominoElement<HTMLDivElement, OptionalTextBox> {
private FlexLayout root = FlexLayout.create();
private TextBox textBox;
private CheckBox checkBox;
public OptionalTextBox(String caption) {
textBox = TextBox.create();
checkBox = CheckBox.create(caption)
.value(true)
.addChangeHandler(value -> textBox.setDisabled(!value));
root
.setDirection(FlexDirection.TOP_TO_BOTTOM)
.appendChild(FlexItem.create().appendChild(checkBox))
.appendChild(FlexItem.create().appendChild(textBox));
init(this);
}
public OptionalTextBox setCaption(String caption) {
checkBox.setLabel(caption);
return this;
}
public String getCaption() {
return checkBox.getLabel();
}
@Override
public HTMLDivElement element() {
return root.element();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment