use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.
the class OrderedDependencyView method onShow.
@Override
protected void onShow() {
Html2Component html2Component = new Html2Component();
html2Component.setId("component");
add(html2Component, new Hr());
NativeButton scripts = new NativeButton("Add scripts", event -> add(new Script2Component()));
scripts.setId("addJs");
add(scripts);
}
use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.
the class ShadowRootView method onShow.
@Override
protected void onShow() {
Div div = new Div();
div.getElement().setAttribute("id", "test-element");
add(div);
ShadowRoot shadowRoot = div.getElement().attachShadow();
Element shadowDiv = ElementFactory.createDiv();
shadowDiv.setText("Div inside shadow DOM");
shadowDiv.setAttribute("id", "shadow-div");
shadowRoot.appendChild(shadowDiv);
Element shadowLabel = ElementFactory.createLabel("Label inside shadow DOM");
shadowLabel.setAttribute("id", "shadow-label");
shadowRoot.appendChild(shadowLabel);
NativeButton removeChild = new NativeButton("Remove the last child from the shadow root", event -> shadowRoot.removeChild(shadowLabel));
removeChild.setId("remove");
add(removeChild);
}
use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.
the class RPCLoggerUI method init.
@Override
protected void init(VaadinRequest request) {
NativeButton button = new NativeButton("Click Me");
button.addClickListener(event -> {
});
Input input = new Input();
add(button, input);
}
use of com.vaadin.flow.component.html.NativeButton in project flow by vaadin.
the class ClientServerCounterUI method init.
@Override
protected void init(VaadinRequest request) {
getReconnectDialogConfiguration().setDialogModal(false);
spacer();
// Client counter
getElement().appendChild(ElementFactory.createDiv("Client counter (click 'increment' to update):"));
Element lbl = ElementFactory.createDiv(clientCounter + "").setAttribute("id", CLIENT_COUNTER_ID);
getElement().appendChild(lbl);
NativeButton button = new NativeButton("Increment", e -> {
clientCounter++;
lbl.setText(clientCounter + "");
});
button.setId(INCREMENT_BUTTON_ID);
getElement().appendChild(button.getElement());
spacer();
/*
* Server counter
*/
getElement().appendChild(ElementFactory.createDiv("Server counter (updates each second by server thread):"));
serverCounterElement = ElementFactory.createDiv().setAttribute("id", SERVER_COUNTER_ID);
serverCounterElement.setText(serverCounter + "");
getElement().appendChild(serverCounterElement);
NativeButton startTimer = new NativeButton("Start timer", e -> {
serverCounter = 0;
if (task != null) {
task.cancel();
}
task = new TimerTask() {
@Override
public void run() {
access(() -> {
serverCounter++;
serverCounterElement.setText(serverCounter + "");
});
}
};
timer.scheduleAtFixedRate(task, 1000, 1000);
});
startTimer.setId(START_TIMER_ID);
getElement().appendChild(startTimer.getElement());
Element stopTimer = ElementFactory.createButton("Stop timer").setAttribute("id", STOP_TIMER_ID);
stopTimer.setText("Stop timer");
stopTimer.addEventListener("click", e -> {
if (task != null) {
task.cancel();
task = null;
}
});
getElement().appendChild(stopTimer);
}
Aggregations