List of usage examples for com.google.gwt.user.client Window alert
public static void alert(String msg)
From source file:com.google.gwt.examples.http.client.PostExample.java
public static void doPost(String url, String postData) { RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url); try {//ww w . j av a 2s . c o m builder.setHeader("Content-Type", "application/x-www-form-urlencoded"); Request response = builder.sendRequest(postData, new RequestCallback() { public void onError(Request request, Throwable exception) { // code omitted for clarity } public void onResponseReceived(Request request, Response response) { // code omitted for clarity } }); } catch (RequestException e) { Window.alert("Failed to send the request: " + e.getMessage()); } }
From source file:com.google.gwt.examples.http.client.TimeoutExample.java
public static void doGetWithTimeout(String url) { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try {/*from w ww . j a v a 2s . c o m*/ /* * wait 2000 milliseconds for the request to complete */ builder.setTimeoutMillis(2000); Request response = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { if (exception instanceof RequestTimeoutException) { // handle a request timeout } else { // handle other request errors } } public void onResponseReceived(Request request, Response response) { // code omitted for clarity } }); } catch (RequestException e) { Window.alert("Failed to send the request: " + e.getMessage()); } }
From source file:com.google.gwt.examples.i18n.MyConstantsExample.java
public void useMyConstants() { MyConstants myConstants = (MyConstants) GWT.create(MyConstants.class); Window.alert(myConstants.helloWorld()); }
From source file:com.google.gwt.examples.MenuBarExample.java
License:Apache License
public void onModuleLoad() { // Make a command that we will execute from all leaves. Command cmd = new Command() { public void execute() { Window.alert("You selected a menu item!"); }/*w w w . ja v a2 s .c o m*/ }; // Make some sub-menus that we will cascade from the top menu. MenuBar fooMenu = new MenuBar(true); fooMenu.addItem("the", cmd); fooMenu.addItem("foo", cmd); fooMenu.addItem("menu", cmd); MenuBar barMenu = new MenuBar(true); barMenu.addItem("the", cmd); barMenu.addItem("bar", cmd); barMenu.addItem("menu", cmd); MenuBar bazMenu = new MenuBar(true); bazMenu.addItem("the", cmd); bazMenu.addItem("baz", cmd); bazMenu.addItem("menu", cmd); // Make a new menu bar, adding a few cascading menus to it. MenuBar menu = new MenuBar(); menu.addItem("foo", fooMenu); menu.addItem("bar", barMenu); menu.addItem("baz", bazMenu); // Add it to the root panel. RootPanel.get().add(menu); }
From source file:com.google.gwt.examples.PushButtonExample.java
License:Apache License
public void onModuleLoad() { // Make a new button that does something when you click it. PushButton b = new PushButton("Jump", "Jump?", new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Crash..."); Window.alert("Uh Oh..."); }//ww w.ja v a 2 s .com }); // In a real application, you would have to have css styles defined for // gwt-PushButton-up,gwt-PushButton-up-hovering,gwt-PushButton-up-disabled, // gwt-PushButton-down,.gwt-PushButton-down-hovering,.gwt-PushButton-down-disabled // Add the push button to the root panel. RootPanel.get().add(b); }
From source file:com.google.gwt.examples.TabBarExample.java
License:Apache License
public void onModuleLoad() { // Create a tab bar with three items. TabBar bar = new TabBar(); bar.addTab("foo"); bar.addTab("bar"); bar.addTab("baz"); // Hook up a tab listener to do something when the user selects a tab. bar.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { // Let the user know what they just did. Window.alert("You clicked tab " + event.getSelectedItem()); }//from www . ja v a 2 s. c o m }); // Just for fun, let's disallow selection of 'bar'. bar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() { public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { if (event.getItem().intValue() == 1) { event.cancel(); } } }); // Add it to the root panel. RootPanel.get().add(bar); }
From source file:com.google.gwt.examples.TimerExample.java
License:Apache License
public void onClick(ClickEvent event) { // Create a new timer that calls Window.alert(). Timer t = new Timer() { @Override//from w w w .ja v a2 s. co m public void run() { Window.alert("Nifty, eh?"); } }; // Schedule the timer to run once in 5 seconds. t.schedule(5000); }
From source file:com.google.gwt.examples.ToggleButtonExample.java
License:Apache License
public void onModuleLoad() { // Make a new button that does something when you click it. final ToggleButton toggleButton = new ToggleButton("Up", "Down"); toggleButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (toggleButton.isDown()) { Window.alert("I have been toggled down"); } else { Window.alert("I have been toggled up"); }// w w w.j av a2 s .c o m } }); // In a real application, you would have to have css styles defined for // gwt-ToggleButton-up,gwt-ToggleButton-up-hovering,gwt-ToggleButton-up-disabled, // gwt-ToggleButton-down,.gwt-ToggleButton-down-hovering,.gwt-ToggleButton-down-disabled // Add the ToggleButton to the root panel. RootPanel.get().add(toggleButton); }
From source file:com.google.gwt.gadgets.sample.mealpreferences.client.MealPreferencesGadget.java
License:Apache License
@Override protected void init(MealPreferences preferences) { initDishes(preferences);/*w ww .j av a2 s. c o m*/ // Create a table with a checklist of all available dishes based on the // user's dietary preferences. Panel p = new DockLayoutPanel(Unit.PX); p.setWidth("100%"); FlexTable ft = new FlexTable(); int index = 0; for (String dish : dishes) { CheckBox cb = new CheckBox(); final String dishCopy = dish; cb.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Your order of " + dishCopy + " will be right up."); } }); ft.setWidget(index, 0, cb); ft.setHTML(index, 1, dish); index++; } p.add(ft); RootLayoutPanel.get().add(p); }
From source file:com.google.gwt.gears.sample.database.client.DatabaseDemo.java
License:Apache License
/** * Remove all phrases from the database. *//*ww w . j a v a 2 s .c o m*/ private void clearPhrases() { try { db.execute("DELETE FROM Phrases"); } catch (DatabaseException e) { Window.alert(e.toString()); } }