Hi,

Any one can verify the following code I have done for the menu
concept..

And let me know in GWT is there any option for the navigation to other
GWT pages via menu

package spec.client;


import com.extjs.gxt.ui.client.widget.Composite;
import com.extjs.gxt.ui.client.widget.LayoutContainer;

import com.extjs.gxt.ui.client.widget.layout.AbsoluteData;
import com.extjs.gxt.ui.client.widget.layout.AbsoluteLayout;

import com.extjs.gxt.ui.client.widget.menu.MenuBar;
import com.extjs.gxt.ui.client.widget.menu.MenuBarItem;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
//import com.google.gwt.user.client.Window;
//import
com.extjs.gxt.ui.client.widget.menu.events.MenuItemClickEvent;

//import com.google.gwt.user.client.Command;
//import com.google.gwt.user.client.ui.MenuBar;
//import com.google.gwt.user.client.ui.MenuItem;

public class MainPanel extends Composite {

        MenuBar menuBar;

        LayoutContainer forecastview;
        LayoutContainer performance;

        int menuNumber = 2;
        int height ,width;
        LayoutContainer contentpanel;
//      EmptyPanel emptypanel;
        public MainPanel() {

                width = com.google.gwt.user.client.Window.getClientWidth()-10;
                height = com.google.gwt.user.client.Window.getClientHeight()-2;
                LayoutContainer rootlayout = new LayoutContainer();
                rootlayout.setLayout(new AbsoluteLayout());
                initComponent(rootlayout);
                rootlayout.setSize(width, height);

                menuBar = new MenuBar();

                        Menu menu2 = new Menu();
                                menu2.setTitle("ODView");
                        MenuItem menu2_1 = new MenuItem("Forecast");

                        MenuItem menu2_2 = new MenuItem("Performance");

                        menu2.add(menu2_1);
                        menu2.add(menu2_2);
                        MenuBarItem menuBarItem2 = new MenuBarItem("ODView", 
menu2);
                                menuBar.add(menuBarItem2);
                        /* */

                rootlayout.add(menuBar, new AbsoluteData(5, 0));
                menuBar.setSize(width, (int)(25));

                height -= 25;

                contentpanel = new LayoutContainer();
//              contentpanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
                contentpanel.setLayout(new AbsoluteLayout());
                contentpanel.setSize(width+10, height);

                rootlayout.add(contentpanel, new AbsoluteData(0, 26));

                forecastview = new LayoutContainer();
                forecastview.setSize(width, height);
                performance = new LayoutContainer();
                performance.setSize(width, height);

                hideAll();

                contentpanel.add(forecastview); // 2
                contentpanel.add(performance); // 3


        menu2_1.addSelectionListener(new SelectionListener<MenuEvent>() {
                public void componentSelected(MenuEvent ce) {
                }
                public void handleEvent(MenuEvent e) {

                        hideAll();
                        forecastview.setVisible(true);
                        contentpanel.repaint();
                }
        });

        menu2_2.addSelectionListener(new SelectionListener<MenuEvent>() {
                public void componentSelected(MenuEvent ce) {
                }
                public void handleEvent(MenuEvent e) {
                        hideAll();
                        performance.setVisible(true);
                        contentpanel.repaint();
                }
        });

}
        public void hideAll()
        {
                forecastview.setVisible(false);
                performance.setVisible(false);
        }

        public void showMainPanel()
        {
                hideAll();
                setVisible(true);
                menuBar.setVisible(true);
                forecastview.setVisible(true);
        }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to