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

public Button(String html, ClickHandler handler) 

Source Link

Document

Creates a button with the given HTML caption and click listener.

Usage

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

License:Apache License

public void onModuleLoad() {
    RootPanel body = RootPanel.get();/* w  w  w.j  av  a2  s  . c  o m*/
    DOM.setStyleAttribute(body.getElement(), "background", "blue");
    body.add(new Button("Show popup", new ClickHandler() {
        public void onClick(ClickEvent event) {
            Button showPopupButton = (Button) event.getSource();
            PopupPanel popup = new PopupPanel(true);
            popup.add(new HTML("Click outside the popup to dismiss it"));
            DOM.setStyleAttribute(popup.getElement(), "border", "solid white 5px");
            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();
        }
    }));
}

From source file:asquare.gwt.tk.demo.client.DebugPanel.java

License:Apache License

private Widget createControlPanel(final DebugEventListener eventListener) {
    BasicPanel controls = new BasicPanel();
    DOM.setAttribute(controls.getElement(), "id", "debug-controls");

    // debug output
    BasicPanel debug = new BasicPanel("p", BasicPanel.DISPLAY_INLINE);
    debug.add(new Label("Debug output ", false));
    debug.add(new Button("enable", new ClickListener() {
        public void onClick(Widget sender) {
            Debug.enable();//ww  w  . ja va 2s.  c om
        }
    }));
    debug.add(new Button("disable", new ClickListener() {
        public void onClick(Widget sender) {
            Debug.disable();
        }
    }));
    controls.add(debug);

    // console
    BasicPanel console = new BasicPanel("p", BasicPanel.DISPLAY_INLINE);
    console.add(new Label("Debug console ", false));
    console.add(new Button("enable", new ClickListener() {
        public void onClick(Widget sender) {
            DebugConsole.getInstance().enable();
        }
    }));
    console.add(new Button("disable", new ClickListener() {
        public void onClick(Widget sender) {
            DebugConsole.getInstance().disable();
        }
    }));
    controls.add(console);

    // event tracing
    BasicPanel tracing = new BasicPanel("p", BasicPanel.DISPLAY_INLINE);
    tracing.add(new Label("Event tracing ", false));
    tracing.add(new Button("enable", new ClickListener() {
        public void onClick(Widget sender) {
            eventListener.enable(true);
            Debug.println("You can trace any event. Some events are ignored by default");
        }
    }));
    tracing.add(new Button("disable", new ClickListener() {
        public void onClick(Widget sender) {
            eventListener.enable(false);
        }
    }));
    controls.add(tracing);

    Widget checkBoxes = createCheckBoxes();
    controls.add(checkBoxes);
    DOM.setStyleAttribute(checkBoxes.getElement(), "display", "block");

    return controls;
}

From source file:asquare.gwt.tk.uitest.glasspanel.client.Demo.java

License:Apache License

public void onModuleLoad() {
    RowPanel outer = new RowPanel();

    Button showGP = new Button("Show GlassPanel", new ClickHandler() {
        public void onClick(ClickEvent event) {
            GlassPanel gp = new GlassPanel();
            gp.addController(new HideGlassPanelController());
            gp.show();//  w ww  . j ava 2 s .c o m
        }
    });
    outer.add(showGP);

    //      Button showOpaqueGP = new Button("Show OpaqueGlassPanel", new ClickListener()
    //      {
    //         public void onClick(Widget sender)
    //         {
    //            GlassPanel gp = new GlassPanel();
    //            gp.addController(new HideGlassPanelController());
    //            gp.addController(new OpaqueController());
    //            gp.show();
    //         }
    //      });
    //      outer.add(showOpaqueGP);

    RootPanel.get().add(outer);
}

From source file:asquare.gwt.tkdemo.client.demos.DebugPanel.java

License:Apache License

private Widget createControlPanel(final DebugEventListener eventListener) {
    BasicPanel outer = new BasicPanel();
    FlexTable table = new FlexTable();
    outer.add(table);//  ww  w.  j a v a  2 s .c om

    // debug output
    table.setHTML(0, 0, "Debug output ");
    table.setWidget(0, 1, new Button("enable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            Debug.enable();
        }
    }));
    table.setWidget(0, 2, new Button("disable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            Debug.disable();
        }
    }));

    table.setHTML(1, 0, "Debug console ");
    table.setWidget(1, 1, new Button("enable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            DebugConsole.getInstance().enable();
        }
    }));
    table.setWidget(1, 2, new Button("disable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            DebugConsole.getInstance().disable();
        }
    }));

    table.setHTML(2, 0, "Event tracing ");
    table.setWidget(2, 1, new Button("enable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            eventListener.enable(true);
            Debug.println("You can trace any event. Some events are ignored by default");
        }
    }));
    table.setWidget(2, 2, new Button("disable", new ClickHandler() {
        public void onClick(ClickEvent event) {
            eventListener.enable(false);
        }
    }));

    table.setWidget(3, 0, createCheckBoxes());
    ((FlexCellFormatter) table.getCellFormatter()).setColSpan(3, 0, 3);

    return outer;
}

From source file:at.ait.dme.yuma.client.map.explore.SearchPanel.java

License:EUPL

public SearchPanel(TiledImageComposite imageComposite) {
    this.searchLayer = imageComposite.getSearchLayer();
    AnnotationConstants i18n = Application.getConstants();

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setStyleName("explore-PlaceSearch");
    Label searchLabel = new Label(i18n.searchLabel());
    searchBox = new TextBox();
    Button searchBtn = new Button(i18n.searchButton(), new ClickHandler() {
        @Override//ww w .  jav  a2  s.c om
        public void onClick(ClickEvent event) {
            doAsyncGeocoding();
        }
    });
    hPanel.add(searchLabel);
    hPanel.add(searchBox);
    hPanel.add(searchBtn);

    this.add(hPanel);
}

From source file:at.ait.dme.yuma.suite.apps.map.client.explore.SearchPanel.java

License:EUPL

public SearchPanel(TileBasedImageViewer imageComposite) {
    this.searchLayer = imageComposite.getSearchLayer();
    I18NConstants i18n = YUMACoreProperties.getConstants();

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setStyleName("explore-PlaceSearch");
    Label searchLabel = new Label(i18n.searchLabel());
    searchBox = new TextBox();
    Button searchBtn = new Button(i18n.searchButton(), new ClickHandler() {
        @Override/*from   ww  w .j av a  2  s .co m*/
        public void onClick(ClickEvent event) {
            doAsyncGeocoding();
        }
    });
    hPanel.add(searchLabel);
    hPanel.add(searchBox);
    hPanel.add(searchBtn);

    this.add(hPanel);
}

From source file:au.com.gworks.gwt.petstore.client.AccountSignInView.java

License:Apache License

public AccountSignInView() {
    setText("Sign In");
    setSize("300", "125");
    setStyleName("ps-SignIn-DialogBox");

    form.addInputText("Username", 20, 15);
    form.addPasswordInputText("Password", 15);
    form.addButton("Sign In");
    form.addButton("Register");
    container.add(form);//  ww w.j a  v a  2s . c om

    Button btnCLose = new Button("Close", this);
    container.add(btnCLose);

    setWidget(container);
}

From source file:binarymillenium.tiles.client.Tiles.java

License:GNU General Public License

public void onModuleLoad() {

    populateMap();//from ww  w . j a v  a  2s.  c o m

    Button forward = new Button("forward", new ClickListener() {
        public void onClick(Widget sender) {
            viewx += viewdirx;
            viewy += viewdiry;
            checkBounds();
            draw();
        }
    });
    RootPanel.get().add(forward);

    Button back = new Button("back", new ClickListener() {
        public void onClick(Widget sender) {
            viewx -= viewdirx;
            viewy -= viewdiry;
            checkBounds();
            draw();
        }
    });
    RootPanel.get().add(back);

    Button left = new Button("left", new ClickListener() {
        public void onClick(Widget sender) {
            viewx -= viewdiry;
            viewy -= viewdirx;
            checkBounds();
            draw();
        }
    });
    RootPanel.get().add(left);

    Button right = new Button("right", new ClickListener() {
        public void onClick(Widget sender) {
            viewx += viewdiry;
            viewy += viewdirx;
            checkBounds();
            draw();
        }
    });
    RootPanel.get().add(right);

    Button turnright = new Button("turn right", new ClickListener() {
        public void onClick(Widget sender) {

            if (viewdirx == 1) {
                viewdirx = 0;
                viewdiry = -1;
            } else if (viewdirx == -1) {
                viewdirx = 0;
                viewdiry = 1;
            } else if (viewdiry == 1) {
                viewdirx = 1;
                viewdiry = 0;
            } else if (viewdiry == -1) {
                viewdirx = -1;
                viewdiry = 0;
            }

            draw();
        }
    });
    RootPanel.get().add(turnright);

    Button turnleft = new Button("turn left", new ClickListener() {
        public void onClick(Widget sender) {

            if (viewdirx == 1) {
                viewdirx = 0;
                viewdiry = 1;
            } else if (viewdirx == -1) {
                viewdirx = 0;
                viewdiry = -1;
            } else if (viewdiry == 1) {
                viewdirx = -1;
                viewdiry = 0;
            } else if (viewdiry == -1) {
                viewdirx = 1;
                viewdiry = 0;
            }

            draw();
        }
    });

    RootPanel.get().add(turnleft);

    focPan = new FocusPanel();
    panel = new AbsolutePanel();
    focPan.add(panel);
    RootPanel.get().add(focPan);

    mappanel = new AbsolutePanel();
    panel.add(mappanel);
    panel.setWidgetPosition(mappanel, 512, 0);
    mappanel.setPixelSize(MAPPANELSIZE, MAPPANELSIZE);
    initmappanel();

    //focPan.addKeyboardListener(new landerHandler());
    //focPan.addMouseListener(new landerHandler2());

    panel.add(sky);
    panel.add(ground);
    panel.setWidgetPosition(ground, 0, 512 / 2);

    initviewobjects();

    panel.setPixelSize(512 + MAPPANELSIZE, 512);
    /// how to specify back to front ordering?
    /// order add and set back to front
    /*for (int i = 0; i < back_wall.length; i++) {
        back_wall[i] = new Image("backwall.png");
        panel.add(back_wall[i]);
        panel.setWidgetPosition(back_wall[i], i*100,512/2-50);
    }*/

    //panel.add(left_wall);
    //panel.setWidgetPosition(left_wall, 0,0);

    draw();
    //new AnimationTimer().scheduleRepeating( (int)(dt*1e3) );
}

From source file:burrito.client.crud.widgets.LinkedEntityWidgetPopup.java

License:Apache License

public LinkedEntityWidgetPopup(final SaveHandler saveHandler) {
    super(false, true);
    setText(labels.createNewLink());//from  ww  w .j av a  2  s .  c o  m
    type.setLabelCreator(new SelectionListLabelCreator<String>() {

        @Override
        public String createLabel(String typeClassName) {
            return CrudLabelHelper.getString(typeClassName.replace('.', '_') + "_singular");
        }
    });
    type.setNullSelectLabel(labels.chooseLinkType());
    type.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            handleTypeChange();
        }
    });

    wrapper.add(new Label(labels.linkText()));
    wrapper.add(linkText);
    wrapper.add(new Label(labels.selectLinkTo()));
    wrapper.add(type);
    wrapper.add(valuesWrapper);

    urlWrapper.setVisible(false);
    urlWrapper.add(new Label(labels.writeOrPasteLink()));
    urlWrapper.add(url);
    wrapper.add(urlWrapper);

    HorizontalPanel hp = new HorizontalPanel();

    hp.add(new Button(labels.save(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            doSave(saveHandler);
        }
    }));
    hp.add(new Button(labels.cancel(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            removeFromParent();
        }
    }));
    wrapper.add(new VerticalSpacer(10));
    wrapper.add(hp);
    setWidget(wrapper);
    addStyleName("k5-LinkedEntityWidget");

    init();
}

From source file:burrito.client.sitelet.SiteletDragAndDropPanel.java

License:Apache License

public SiteletDragAndDropPanel(final String containerName) {
    super();/* w  w  w . ja v  a 2 s  . c  om*/
    widgetCreator.setContainerName(containerName);
    Hyperlink addSitelet = new Hyperlink(labels.addSitelet(), "-1");

    wrapper.add(addSitelet);

    saveOrderButton = new Button(labels.saveOrder(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            service.saveSiteletOrder(containerName, currentOrder, new AsyncCallback<Void>() {

                @Override
                public void onSuccess(Void result) {
                    InfoMessagePopup popup = new InfoMessagePopup();
                    popup.setTextAndShow(labels.orderSaved());
                    orderChangedPanel.setVisible(false);
                }

                @Override
                public void onFailure(Throwable caught) {
                    throw new RuntimeException("Failed to save order", caught);
                }
            });

        }
    });
    orderChangedPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    orderChangedPanel.add(new Label(labels.orderChanged()));
    orderChangedPanel.add(new HTML("&nbsp;"));
    orderChangedPanel.add(saveOrderButton);
    orderChangedPanel.setVisible(false);

    service.getSitelets(containerName, new AsyncCallback<List<SiteletDescription>>() {

        @Override
        public void onSuccess(final List<SiteletDescription> result) {
            currentModel = result;
            render();
        }

        @Override
        public void onFailure(Throwable caught) {
            throw new RuntimeException("Failed to load sitelets for container " + containerName, caught);
        }
    });
    wrapper.add(siteletsContainer);
    wrapper.add(orderChangedPanel);
    initWidget(wrapper);
}