Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Tutorials Gwt Creating Menu using GWT

Related Tutorials


Share on Google+Share on Google+

Creating Menu using GWT

This example describes the Basics for building the Menu using GWT.

Creating Menu using GWT


This example describes the Basics for building the Menu using GWT. The steps involved in Building the Menu Structure are described below:-

final Label label = new Label("Move the cursor over the Menu item")
Here we are declaring label. Label is a widget that contains text.

Command cmd = new Command()
Command is an interface that encapsulates an action for execution. This Interface can be often implemented with an anonymous inner class.

Window.alert("Menu item have been selected")
This is an alert whenever an Menu item is selected.

Menu Bar File = new MenuBar(true)
Creating a Menu bar named File. A Menu bar can contain any number of items.

This is a method for adding item to the Menubar.Here we are adding New to the Menu bar named File

package org.yournamehere.client;

public class MenuBarex implements EntryPoint{

 public void onModuleLoad() {
 final Label label = new Label("Move the cursor over the Menuitem");
 final Label label1 = new Label("");
 Command cmd = new Command() {
  public void execute() {
  Window.alert("Menu item have been selected");
  MenuBar File = new MenuBar(true);

  MenuBar Edit = new MenuBar(true);
  Edit.addItem("Undo", cmd);
  Edit.addItem("Redo", cmd);
  Edit.addItem("Cut", cmd);
  Edit.addItem("Copy", cmd);

  MenuBar Format = new MenuBar(true);
  Format.addItem("Word wrap", cmd);
  Format.addItem("Font", cmd);
  MenuBar menu = new MenuBar();
  menu.addItem("File", File);
  menu.addItem("Edit", Edit);
  menu.addItem("Format", Format);


<?xml version="1.0" encoding="UTF-8"?>
  <inherits name=""/>
  <entry-point class="org.yournamehere.client.MenuBarex"/>

Output of the program

Download source code



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 6, 2008

Related Tutorials

Discuss: Creating Menu using GWT   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
October 29, 2012

u r did a great job like simple techniques..thans a lot