Search in sources :

Example 21 with NativeButton

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);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Hr(com.vaadin.flow.component.html.Hr)

Example 22 with NativeButton

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);
}
Also used : Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) Element(com.vaadin.flow.dom.Element) ShadowRoot(com.vaadin.flow.dom.ShadowRoot)

Example 23 with NativeButton

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);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Input(com.vaadin.flow.component.html.Input)

Example 24 with NativeButton

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);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) TimerTask(java.util.TimerTask) Element(com.vaadin.flow.dom.Element)

Aggregations

NativeButton (com.vaadin.flow.component.html.NativeButton)24 Div (com.vaadin.flow.component.html.Div)9 Text (com.vaadin.flow.component.Text)4 Hr (com.vaadin.flow.component.html.Hr)3 Input (com.vaadin.flow.component.html.Input)3 Label (com.vaadin.flow.component.html.Label)3 AttachEvent (com.vaadin.flow.component.AttachEvent)2 Component (com.vaadin.flow.component.Component)2 UI (com.vaadin.flow.component.UI)2 Element (com.vaadin.flow.dom.Element)2 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)2 Route (com.vaadin.flow.router.Route)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HasText (com.vaadin.flow.component.HasText)1 HasValidation (com.vaadin.flow.component.HasValidation)1 Html (com.vaadin.flow.component.Html)1 Paragraph (com.vaadin.flow.component.html.Paragraph)1 Push (com.vaadin.flow.component.page.Push)1 Style (com.vaadin.flow.dom.Style)1