Example usage for com.google.gwt.user.client.ui Button Button

List of usage examples for com.google.gwt.user.client.ui Button Button

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Button Button.

Prototype

protected Button(com.google.gwt.dom.client.Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:$.GwtApp.java

License:GNU General Public License

@Override
    public void onModuleLoad() {
        RootPanel.get().add(new Button("Click Me"));
    }

From source file:$.HelloPlugins.java

License:Apache License

@Override
    public void onModuleLoad() {
        Image img = new Image("http://code.google.com/webtoolkit/logo-185x175.png");
        Button button = new Button("Click me");

        VerticalPanel vPanel = new VerticalPanel();
        vPanel.setWidth("100%");
        vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        vPanel.add(img);//from  w  ww.j  ava  2 s  .  c  om
        vPanel.add(button);

        RootPanel.get().add(vPanel);

        // Create the dialog box
        final DialogBox dialogBox = new DialogBox();

        // The content of the dialog comes from a User specified Preference
        dialogBox.setText("Hello from GWT Gerrit UI plugin");
        dialogBox.setAnimationEnabled(true);
        Button closeButton = new Button("Close");
        VerticalPanel dialogVPanel = new VerticalPanel();
        dialogVPanel.setWidth("100%");
        dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        dialogVPanel.add(closeButton);

        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                dialogBox.hide();
            }
        });

        // Set the contents of the Widget
        dialogBox.setWidget(dialogVPanel);

        button.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                dialogBox.center();
                dialogBox.show();
            }
        });
    }

From source file:ar.com.cristal.creditos.client.tambo.partediario.celoservicio.PdCeloServicioActivity.java

License:Open Source License

private void agregarCeloServicioATabla(CeloServicioDTO c) {
     int i = view.lstCelosServicios.getRowCount() - 1;

     view.lstCelosServicios.setText(i + 1, 0, String.valueOf(c.getId()));
     view.lstCelosServicios.setText(i + 1, 1, c.getVaca().getRp());
     view.lstCelosServicios.setText(i + 1, 2, String.valueOf(c.getNroCeloServicio()));
     view.lstCelosServicios.setText(i + 1, 3, String.valueOf(c.getLactancia()));
     view.lstCelosServicios.setText(i + 1, 4, c.getTipo().getItemText());
     view.lstCelosServicios.setText(i + 1, 5, (c.getToro() != null) ? c.getToro().getNombre() : "");
     view.lstCelosServicios.setText(i + 1, 6,
             (c.getTipoServicio() != null) ? c.getTipoServicio().getDescripcion() : "");
     view.lstCelosServicios.setText(i + 1, 7,
             (c.getInseminador() != null) ? c.getInseminador().getItemText() : "");

     //Boton Elimimnar
     Button cmdEliminarCeloServicio = new Button("Eliminar");
     cmdEliminarCeloServicio.addClickHandler(new ClickHandler() {
         public void onClick(ClickEvent event) {
             Cell cellSelected = view.lstCelosServicios.getCellForEvent(event);
             int rowSelected = cellSelected.getRowIndex();
             Long idCeloServicio = Long.valueOf(view.lstCelosServicios.getText(rowSelected, 0));
             eliminarCeloServicio(idCeloServicio);
         }// w  w  w  .j  a va  2  s  .  c om
     });
     view.lstCelosServicios.setWidget(i + 1, 8, cmdEliminarCeloServicio);

     if (i % 2 == 0) {
         view.lstCelosServicios.getRowFormatter().addStyleName(i + 1, "TableRow1Pointer");
     } else {
         view.lstCelosServicios.getRowFormatter().addStyleName(i + 1, "TableRow2Pointer");
     }

 }

From source file:ar.com.cristal.creditos.client.tambo.partediario.parto.PdPartoActivity.java

License:Open Source License

private void agregarPartoATabla(PartoDTO c) {
     int i = view.lstCelosServicios.getRowCount() - 1;

     view.lstCelosServicios.setText(i + 1, 0, String.valueOf(c.getId()));
     view.lstCelosServicios.setText(i + 1, 1, c.getVaca().getRp());
     view.lstCelosServicios.setText(i + 1, 2, c.getPadre().getNombre());
     view.lstCelosServicios.setText(i + 1, 3, String.valueOf(c.getNroParto()));
     view.lstCelosServicios.setText(i + 1, 4, c.getTipoParto().getItemText());
     view.lstCelosServicios.setText(i + 1, 5, (c.getSexoCria1() != null) ? c.getSexoCria1().getItemText() : "");
     view.lstCelosServicios.setText(i + 1, 6,
             (c.getEstadoCria1() != null) ? c.getEstadoCria1().getItemText() : "");
     view.lstCelosServicios.setText(i + 1, 7, (c.getSexoCria2() != null) ? c.getSexoCria2().getItemText() : "");
     view.lstCelosServicios.setText(i + 1, 8,
             (c.getEstadoCria2() != null) ? c.getEstadoCria2().getItemText() : "");
     view.lstCelosServicios.setText(i + 1, 9, (c.isMellizos()) ? "SI" : "NO");

     //Boton Elimimnar
     Button cmdEliminarParto = new Button("Eliminar");
     cmdEliminarParto.addClickHandler(new ClickHandler() {
         public void onClick(ClickEvent event) {
             Cell cellSelected = view.lstCelosServicios.getCellForEvent(event);
             int rowSelected = cellSelected.getRowIndex();
             Long idCeloServicio = Long.valueOf(view.lstCelosServicios.getText(rowSelected, 0));
             //eliminarCeloServicio (idCeloServicio);
             popup.mostrarMensaje("Falta implementar");
         }//  w w w.ja v  a2s  .  c o  m
     });
     view.lstCelosServicios.setWidget(i + 1, 10, cmdEliminarParto);

     if (i % 2 == 0) {
         view.lstCelosServicios.getRowFormatter().addStyleName(i + 1, "TableRow1Pointer");
     } else {
         view.lstCelosServicios.getRowFormatter().addStyleName(i + 1, "TableRow2Pointer");
     }

 }

From source file:asquare.gwt.debug.client.DebugConsole.java

License:Apache License

/**
 * Creates the console, installs the enabler key listener. 
 * The console is not yet attached to the DOM. 
 *//*from  w  w w  .  java 2s.c o  m*/
protected DebugConsole() {
    super(false, false);
    setStyleName("tk-DebugConsole");
    DOM.setStyleAttribute(getElement(), "border", "solid black 1px");
    DOM.setStyleAttribute(getElement(), "background", "white");

    setHTML("<div style='margin: 2px; padding: 3px; background-color: rgb(195, 217, 255); font-weight: bold; font-size: smaller; cursor: default;'>Debug Console</div>");

    m_content.setWordWrap(false);
    DOM.setStyleAttribute(m_content.getElement(), "margin", "2px");
    DOM.setStyleAttribute(m_content.getElement(), "padding", "3px");

    VerticalPanel outer = new VerticalPanel();

    ScrollPanel scrollPanel = new ScrollPanel(m_content);
    scrollPanel.setAlwaysShowScrollBars(true);
    scrollPanel.setSize("40em", "20em");
    outer.add(scrollPanel);

    HorizontalPanel controls = new HorizontalPanel();
    DOM.setStyleAttribute(controls.getElement(), "margin", "2px");
    controls.setWidth("100%");
    outer.add(controls);

    HorizontalPanel controlsLeft = new HorizontalPanel();
    controls.add(controlsLeft);
    controls.setCellHorizontalAlignment(controlsLeft, HorizontalPanel.ALIGN_LEFT);

    HorizontalPanel controlsRight = new HorizontalPanel();
    controls.add(controlsRight);
    controls.setCellHorizontalAlignment(controlsRight, HorizontalPanel.ALIGN_RIGHT);

    final Button toggleDebugButton = new Button("Toggle&nbsp;Debug");
    DOM.setElementProperty(toggleDebugButton.getElement(), "title", "Toggles output of debug statements");
    controlsLeft.add(toggleDebugButton);

    updateDisableButtonText();
    DOM.setElementProperty(m_disableButton.getElement(), "title",
            "Prevents this console from appearing when debug statements are printed");
    controlsLeft.add(m_disableButton);

    final Button clearButton = new Button("Clear");
    DOM.setElementProperty(clearButton.getElement(), "title", "Clears all messages in the console");
    controlsRight.add(clearButton);

    final Button hideButton = new Button("Hide");
    DOM.setStyleAttribute(hideButton.getElement(), "textAlign", "right");
    controlsRight.add(hideButton);

    setWidget(outer);
    m_left = Window.getClientWidth() / 2 - 640 / 2;
    m_top = Window.getClientHeight() / 2;

    m_enabler.install();

    ClickHandler handler = new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (sender == clearButton) {
                clearMessages();
            } else if (sender == hideButton) {
                hide();
            } else if (sender == m_disableButton) {
                disable();
            } else if (sender == toggleDebugButton) {
                if (Debug.isEnabled()) {
                    Debug.disable();
                } else {
                    Debug.enable();
                }
            } else {
                assert false;
            }
        }
    };
    toggleDebugButton.addClickHandler(handler);
    m_disableButton.addClickHandler(handler);
    clearButton.addClickHandler(handler);
    hideButton.addClickHandler(handler);

    sinkEvents(Event.ONMOUSEDOWN);
    preventSelectionInIE(getElement());
}

From source file:asquare.gwt.tests.buttonblur.client.Demo.java

License:Apache License

private Widget createDemoPanel() {
    Button result = new Button("gwtButton");
    result.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            Debug.println("gwtButton.onFocus()");
        }/*from  w w w.j  a  va 2 s .  co  m*/
    });
    result.addBlurHandler(new BlurHandler() {
        public void onBlur(BlurEvent event) {
            Debug.println("gwtButton.onLostFocus()");
        }
    });
    return result;
}

From source file:asquare.gwt.tests.buttonclick.client.Demo.java

License:Apache License

public void onModuleLoad() {
    Button m_button1 = new Button("Click me");
    final Button m_button2 = new Button("Target button");
    m_button1.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            m_button2.click();// w  w w . ja v  a2  s  . c  o m
        }
    });
    m_button2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("target button click() called");
        }
    });
    RootPanel.get().add(m_button1);
    RootPanel.get().add(m_button2);
}

From source file:asquare.gwt.tests.focus.client.Demo.java

License:Apache License

private Widget createFocusPanel() {
    Table outer = new Table();

    outer.add(new FocusPanel(new Label("Label in a FocusPanel")));
    outer.add(new Button("Button"));
    outer.add(new CheckBox("CheckBox"));
    outer.add(new TextBox());
    outer.add(new PasswordTextBox());
    outer.add(new TextArea());
    outer.add(new RadioButton("group1", "RadioButton1"));
    outer.add(new RadioButton("group1", "RadioButton2"));
    ListBox listBox1 = new ListBox();
    listBox1.addItem("ListBox1");
    listBox1.addItem("item2");
    listBox1.addItem("item3");
    outer.add(listBox1);//w  ww.  j  a v  a  2 s . c o m
    ListBox listBox2 = new ListBox(true);
    listBox2.setVisibleItemCount(3);
    listBox2.addItem("ListBox2");
    listBox2.addItem("item2");
    listBox2.addItem("item3");
    outer.add(listBox2);
    Tree tree = new Tree();
    tree.addItem("Tree");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree);

    return outer;
}

From source file:asquare.gwt.tests.focusevent.client.Demo.java

License:Apache License

private Widget createDemoPanel() {
    TestPanel outer = new TestPanel();

    outer.add(new Label("GWT onfocus Event Handler"));
    outer.add(new Button("Button"), "Button");
    outer.add(new CheckBox("CheckBox"), "CheckBox");
    outer.add(new RadioButton("group1", "RadioButton1"), "RadioButton1");
    TextBox textBox = new TextBox();
    textBox.setText("TextBox");
    outer.add(textBox, "TextBox");
    PasswordTextBox passwordTextBox = new PasswordTextBox();
    passwordTextBox.setText("PasswordTextBox");
    outer.add(passwordTextBox, "PasswordTextBox");
    TextArea textArea = new TextArea();
    textArea.setText("TextArea");
    outer.add(textArea, "TextArea");
    ListBox listBox = new ListBox();
    listBox.addItem("ListBox");
    listBox.addItem("item2");
    listBox.addItem("item3");
    outer.add(listBox, "ListBox");
    outer.add(new FocusPanel(new Label("Label in a FocusPanel")), "FocusPanel");
    Tree tree = new Tree();
    tree.addItem("item1");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree, "Tree");

    return outer;
}

From source file:asquare.gwt.tests.popuphidden.client.Demo.java

License:Apache License

public void onModuleLoad() {
    RootPanel body = RootPanel.get();//  ww  w. j  a v a  2 s .  c o  m
    DOM.setStyleAttribute(body.getElement(), "background", "blue");
    final Button showPopupButton = new Button("Show popup");
    showPopupButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final PopupPanel popup = new PopupPanel(true);
            VerticalPanel outer = new VerticalPanel();
            outer.add(new HTML("Click outside the popup to dismiss it"));
            outer.add(new Button("DOM.setStyleAttribute(popup.getElement(), \"visibility\", \"hidden\")",
                    new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            DOM.setStyleAttribute(popup.getElement(), "visibility", "hidden");
                        }
                    }));
            popup.setWidget(outer);
            DOM.setStyleAttribute(popup.getElement(), "border", "double black 4px");
            DOM.setStyleAttribute(popup.getElement(), "background", "red");
            popup.setSize("20em", "20em");
            int x = showPopupButton.getAbsoluteLeft();
            int y = showPopupButton.getAbsoluteTop() + showPopupButton.getOffsetHeight();
            popup.setPopupPosition(x, y);
            popup.show();
        }
    });
    body.add(showPopupButton);
}