Using ButtonBar to hold buttons (Ext GWT) : ToolBar « GWT « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Java » GWT » ToolBarScreenshots 
Using ButtonBar to hold buttons (Ext GWT)
Using ButtonBar to hold buttons (Ext GWT)
 
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 
 * http://extjs.com/license
 */

package com.google.gwt.sample.hello.client;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.ProgressBar;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
import com.extjs.gxt.ui.client.widget.layout.FlowData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello implements EntryPoint {
  public void onModuleLoad() {
    RootPanel.get().add(new MessageBoxExample());
  }
}
class MessageBoxExample extends LayoutContainer {

  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    final Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
      public void handleEvent(MessageBoxEvent ce) {
        Button btn = ce.getButtonClicked();
        Info.display("MessageBox""The '{0}' button was pressed", btn.getText());
      }
    };

    final ButtonBar buttonBar = new ButtonBar();
    buttonBar.setMinButtonWidth(75);
    
    buttonBar.add(new Button("Confirm"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        MessageBox.confirm("Confirm""Are you sure you want to do that?", l);
      }
    }));

    buttonBar.add(new Button("Prompt"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        final MessageBox box = MessageBox.prompt("Name""Please enter your name:");
        box.addCallback(new Listener<MessageBoxEvent>() {
          public void handleEvent(MessageBoxEvent be) {
            Info.display("MessageBox""You entered '{0}'"new Params(be.getValue()));
          }
        });
      }
    }));

    buttonBar.add(new Button("Multiline Prompt"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        MessageBox box = MessageBox.prompt("Address""Please enter your address:"true);
        box.addCallback(new Listener<MessageBoxEvent>() {
          public void handleEvent(MessageBoxEvent be) {
            String v = Format.ellipse(be.getValue()80);
            Info.display("MessageBox""You entered '{0}'"new Params(v));
          }
        });
      }
    }));

    buttonBar.add(new Button("Yes/No/Cancel"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        MessageBox box = new MessageBox();
        box.setButtons(MessageBox.YESNOCANCEL);
        box.setIcon(MessageBox.QUESTION);
        box.setTitle("Save Changes?");
        box.addCallback(l);
        box.setMessage("You are closing a tab that has unsaved changes. Would you like to save your changes?");
        box.show();
      }
    }));

    buttonBar.add(new Button("Progress"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        final MessageBox box = MessageBox.progress("Please wait""Loading items...",
            "Initializing...");
        final ProgressBar bar = box.getProgressBar();
        final Timer t = new Timer() {
          float i;

          @Override
          public void run() {
            bar.updateProgress(i / 100(inti + "% Complete");
            i += 5;
            if (i > 105) {
              cancel();
              box.close();
              Info.display("Message""Items were loaded""");
            }
          }
        };
        t.scheduleRepeating(500);
      }
    }));

    buttonBar.add(new Button("Wait"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        final MessageBox box = MessageBox.wait("Progress",
            "Saving your data, please wait...""Saving...");
        Timer t = new Timer() {
          @Override
          public void run() {
            Info.display("Message""Your fake data was saved""");
            box.close();
          }
        };
        t.schedule(5000);
      }
    }));

    buttonBar.add(new Button("Alert"new SelectionListener<ButtonEvent>() {
      public void componentSelected(ButtonEvent ce) {
        MessageBox.alert("Alert""Access Denied", l);
      }
    }));
    add(buttonBar, new FlowData(10));
  }

}

   
  
Ext-GWT.zip( 4,297 k)
Related examples in the same category
1.Tool Strips Sample (Smart GWT)Tool Strips Sample (Smart GWT)
2.Adding ComboBox to ToolBar (Ext GWT)Adding ComboBox to ToolBar (Ext GWT)
3.ToolBar overflow (Ext GWT)
4.ToolBar with Dropdown menu (Ext GWT)ToolBar with Dropdown menu (Ext GWT)
5.Ribbon like ToolBar (Ext GWT)Ribbon like ToolBar (Ext GWT)
6.Multi-column no-title ToolBar (Ext GWT)Multi-column no-title ToolBar (Ext GWT)
7.ToolBar with grouped buttons (Ext GWT)ToolBar with grouped buttons (Ext GWT)
8.Office 2007 style toolbar (Ext GWT)Office 2007 style toolbar (Ext GWT)
9.Adding menu bar to ContentPanel (Ext GWT)Adding menu bar to ContentPanel (Ext GWT)
10.Adding Status to ToolBar (Ext GWT)Adding Status to ToolBar (Ext GWT)
11.Add ToolBar to the bottom of a FormPanel (Ext GWT)Add ToolBar to the bottom of a FormPanel (Ext GWT)
12.Adding ToolBar to ContentPanel (Ext GWT)Adding ToolBar to ContentPanel (Ext GWT)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.