List of usage examples for com.google.gwt.user.client.ui Button Button
protected Button(com.google.gwt.dom.client.Element element)
From source file:com.google.gwt.examples.FlexTableExample.java
License:Apache License
public void onModuleLoad() { // Tables have no explicit size -- they resize automatically on demand. FlexTable t = new FlexTable(); // Put some text at the table's extremes. This forces the table to be // 3 by 3.//from w w w . ja v a2 s . c o m t.setText(0, 0, "upper-left corner"); t.setText(2, 2, "bottom-right corner"); // Let's put a button in the middle... t.setWidget(1, 0, new Button("Wide Button")); // ...and set it's column span so that it takes up the whole row. t.getFlexCellFormatter().setColSpan(1, 0, 3); RootPanel.get().add(t); }
From source file:com.google.gwt.examples.GridExample.java
License:Apache License
public void onModuleLoad() { // Grids must be sized explicitly, though they can be resized later. Grid g = new Grid(5, 5); // Put some values in the grid cells. for (int row = 0; row < 5; ++row) { for (int col = 0; col < 5; ++col) g.setText(row, col, "" + row + ", " + col); }//from w ww . j a v a 2 s . co m // Just for good measure, let's put a button in the center. g.setWidget(2, 2, new Button("Does nothing, but could")); // You can use the CellFormatter to affect the layout of the grid's cells. g.getCellFormatter().setWidth(0, 2, "256px"); RootPanel.get().add(g); }
From source file:com.google.gwt.examples.PopupPanelExample.java
License:Apache License
public void onModuleLoad() { Button b1 = new Button("Click me to show popup"); b1.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Instantiate the popup and show it. new MyPopup().show(); }/*from w w w . ja v a 2 s . co m*/ }); RootPanel.get().add(b1); Button b2 = new Button("Click me to show popup partway across the screen"); b2.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Create the new popup. final MyPopup popup = new MyPopup(); // Position the popup 1/3rd of the way down and across the screen, and // show the popup. Since the position calculation is based on the // offsetWidth and offsetHeight of the popup, you have to use the // setPopupPositionAndShow(callback) method. The alternative would // be to call show(), calculate the left and top positions, and // call setPopupPosition(left, top). This would have the ugly side // effect of the popup jumping from its original position to its // new position. popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = (Window.getClientWidth() - offsetWidth) / 3; int top = (Window.getClientHeight() - offsetHeight) / 3; popup.setPopupPosition(left, top); } }); } }); RootPanel.get().add(b2); }
From source file:com.google.gwt.examples.TimerExample.java
License:Apache License
public void onModuleLoad() { Button b = new Button("Click and wait 5 seconds"); b.addClickHandler(this); RootPanel.get().add(b);/*from www .j a va2 s . c om*/ }
From source file:com.google.gwt.gadgets.sample.basicgadgetads.client.BasicGadgetAds.java
License:Apache License
@Override protected void init(AdsUserPreferences preferences) { // Creating the Panel VerticalPanel vp = new VerticalPanel(); RootPanel.get().add(vp);/* w w w .j ava2 s . c o m*/ // Setting style and alignment vp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // Using GadgetImage instead of Image will cache your images on the // Gadget's Container server. It is a Gadget Ads requirement that all // embedded assets must be cached. vp.add(new GadgetImage("http://code.google.com/webtoolkit/images/gwt-logo.png")); // Adding a waiting message to the RootPanel Label disclaimer = new Label("Use GWT for your Gadget Ads!"); vp.add(disclaimer); // Another Logo vp.add(new GadgetImage("http://code.google.com/webtoolkit/images/gwt-logo.png")); // Adding the button to go to the GWT website Button button = new Button("Visit the GWT Website NOW!!"); vp.add(button); // When clicking the button, we are redirected to the GWT website. // We use the AdsFeature.clickDestinationUrl() which will redirect to the // URL and report the clickthrough hit. // It is a GadgetAds requirement to use some AdsFeature.reportInteraction() // or AdsFeature.clickDestinationUrl() button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { adsFeature.clickDestinationUrl("http://code.google.com/webtoolkit/"); } }); // Another Logo vp.add(new GadgetImage("http://code.google.com/webtoolkit/images/gwt-logo.png")); // Some styling vp.setHeight("100%"); vp.setWidth("100%"); button.setWidth("80%"); button.getElement().getStyle().setProperty("cursor", "pointer"); button.getElement().getStyle().setPropertyPx("fontSize", 15); button.getElement().getStyle().setProperty("fontWeight", "bold"); button.getElement().getStyle().setPropertyPx("padding", 5); }
From source file:com.google.gwt.gadgets.sample.gadgetrpc.client.GadgetRPC.java
License:Apache License
@Override protected void init(GadgetRPC.Preferences preferences) { gadgetService = GWT.create(GadgetService.class); ServiceDefTarget serviceDef = (ServiceDefTarget) gadgetService; String rpcUrl = serviceDef.getServiceEntryPoint(); // Uses Gadgets container as proxy for GWT RPC requests GadgetsGwtRpc.redirectThroughProxy(serviceDef); // Build the user interface. VerticalPanel vp = new VerticalPanel(); vp.setWidth("100%"); vp.add(new Label("RPC to: " + rpcUrl)); HorizontalPanel startedHp = new HorizontalPanel(); startedHp.add(new Label("Server Start Time: ")); startedHp.add(serverStartedText);/* w ww . j av a2s .co m*/ vp.add(startedHp); HorizontalPanel currentHp = new HorizontalPanel(); currentHp.add(new Label("Server Current Time: ")); currentHp.add(serverCurrentText); vp.add(currentHp); Button doRPCButton = new Button("Call RPC Method"); vp.add(doRPCButton); vp.add(exceptionInfo); RootPanel.get().add(vp); // Setup a button listener to invoke the RPC. doRPCButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { gadgetService.getServerInfo(rpcCallback); } }); }
From source file:com.google.gwt.gadgets.sample.hellogadgets.client.HelloGadgets.java
License:Apache License
@Override protected void init(final HelloPreferences prefs) { 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 w w.ja v a 2 s . c o m 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(prefs.promptSomethingElse().getValue()); 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:com.google.gwt.gadgets.sample.simplegadget.client.SimpleGadget.java
License:Apache License
@Override protected void init(UserPreferences preferences) { Button changeTitleButton = new Button("Change Title"); changeTitleButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { titleFeature.setTitle(titles[titleIndex++ % titles.length]); }/* w w w. jav a 2s .c o m*/ }); RootLayoutPanel.get().add(changeTitleButton); }
From source file:com.google.gwt.gadgets.sample.traveler.client.ErrorNotifier.java
License:Apache License
private ErrorNotifier() { dialogBox = new DialogBox(); dialogBox.setText("Error occurred"); dialogBox.setAnimationEnabled(true); codeLabel = new Label(); detailsHTML = new HTML(); detailsHTML.setVisible(false);//ww w . j av a2s . c o m detailsButton = new Button("Show details"); detailsButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { toggleDetails(); } }); final Button closeButton = new Button("Close"); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.setStylePrimaryName("error-panel"); dialogVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dialogVPanel.add(codeLabel); dialogVPanel.add(detailsHTML); FlowPanel buttons = new FlowPanel(); buttons.add(detailsButton); buttons.add(closeButton); dialogVPanel.add(buttons); dialogBox.setWidget(dialogVPanel); }
From source file:com.google.gwt.gadgets.sample.traveler.client.PersonBrowser.java
License:Apache License
/** * Constructs widget using given {@link PeopleService}. * * @param people {@link PeopleService} instance being a source of data. * @param height height of the gadget.// www .ja v a 2s. c om * @param noPhotoUrl url to the thumbnail to be used if thumbnail for a * displayed friend is unavailable. */ public PersonBrowser(PeopleService people, int height, String noPhotoUrl) { this.people = people; this.cellSize = height; this.noPhotoUrl = noPhotoUrl; DockLayoutPanel panel = new DockLayoutPanel(Unit.PX); friendsGrid = new Grid(1, pageSize); friendsGrid.setWidth("100%"); friendsGrid.setCellPadding(0); friendsGrid.setCellSpacing(0); Button prevButton = new Button("<"); Button nextButton = new Button(">"); prevButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { start = Math.max(start - 1, 0); showItems(); } }); nextButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { start = Math.min(start + 1, Math.max(total - pageSize, 0)); showItems(); } }); panel.addWest(prevButton, BUTTON_WIDTH); panel.addEast(nextButton, BUTTON_WIDTH); panel.add(friendsGrid); showItems(); initWidget(panel); }