Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13th Mar 2009, 03:40
dfreire dfreire is offline
Registered Developer
 
Join Date: Mar 2009
Posts: 43
Default Making MenuBar look like a Menu Bar

Hello,

Maybe I'm doing something wrong but I can't make my MenuBar look like a normal menu bar, i.e. visible with 100% width on the NORTH of the page.

Here's my code:
Code:
private MenuBar createMenu() {

    MenuBar menuBar = new MenuBar();
    menuBar.setWidth100();

    Menu userMenu = new Menu();
    userMenu.setShowShadow(true);
    userMenu.setShadowDepth(10);
    String username = controllers.getSecurityControl().getUserSession().getUsername();
    userMenu.setTitle(username);

    MenuItem logoutMenuItem = new MenuItem("Logout");
    logoutMenuItem.addClickHandler(new ClickHandler() {
        public void onClick(MenuItemClickEvent event) {
            controllers.getSecurityControl().logout();
        }
    });
    userMenu.setItems(logoutMenuItem);

    menuBar.setMenus(userMenu);

    return menuBar;
}
I have the result of this in the screenshot attached.

The MenuBar is using 100% width, but only the menu part is visible. I want to have all the MenuBar visible on the top, with the same look & feel as the individual menu.

How can I do this?

Thanks in advance
Attached Images
File Type: png MenuBarProblem.png (14.2 KB, 129 views)
Reply With Quote
  #2  
Old 13th Mar 2009, 06:46
victor.salvalagio victor.salvalagio is offline
Registered Developer
 
Join Date: Feb 2009
Posts: 9
Default

Try use a ToolStrip instead of a MenuBar..

With me worked fine
Reply With Quote
  #3  
Old 16th Mar 2009, 03:04
dfreire dfreire is offline
Registered Developer
 
Join Date: Mar 2009
Posts: 43
Default

Thanks for the reply, but I got the same effect with the ToolStrip...
I can set the background color of the ToolStrip, but I can't set the same look & feel as the individual menu.
Reply With Quote
  #4  
Old 9th Nov 2009, 12:51
toggle57 toggle57 is offline
Registered Developer
 
Join Date: Nov 2009
Posts: 36
Default MenuBar look like a Menu Bar

I am having exactly the same problem.

With all due respect to the single person that answered this question.... is there a better answer?

Is it unreasonable to want a MenuBar that draws itself 100% across the containing widget like any other pull down menu?
Reply With Quote
  #5  
Old 9th Nov 2009, 12:53
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,520
Default

width:"100%" works but you appear to be within a container who's specified size is smaller than the entire width of the page. Use the Watch tab to understand what's going on - compare specified size to drawn size and realize that 100% means 100% of specified size, not drawn size.
Reply With Quote
  #6  
Old 9th Nov 2009, 14:22
toggle57 toggle57 is offline
Registered Developer
 
Join Date: Nov 2009
Posts: 36
Default

Thanks for your reply. I have included my code below and have tried numerous permutations so get that bar to go across the top of the display with now luck.

As you can see the control is menuBar whichis set to width 100% and it resides in the container: vLayout which is also set to 100%.

I am new to SmartGWT and dont know what container vLayout is connected to but I am presuming it is connected to the browser window.

I set a break point and looked at these two objects but I cant see anything (public) that would tell me what the item's size is - I also have no idea what you mean by "specified" versus "drawn" size... do these map to specific methods, or fields? and if so on what object.

Thanks for your help.

public void onModuleLoad() {
VantageConstants constants = (VantageConstants) GWT
.create(VantageConstants.class);

MenuBar menuBar = new MenuBar();
menuBar.setWidth("100%");

Menu menuApplications = new Menu();
menuApplications.setTitle(constants.MenuApplicatio ns());

MenuItem menuItemApplications_Products = new MenuItem(constants.MenuApplications_Products());
menuItemApplications_Products.addClickHandler(new DummyCommand());
menuApplications.addItem(menuItemApplications_Prod ucts);

menuBar.setMenus(menuApplications);

VLayout vLayout = new VLayout();
vLayout.addMember(menuBar);
vLayout.setHeight("100%");
vLayout.setWidth("100%");
vLayout.draw();

}

public class DummyCommand implements ClickHandler {
public void onClick(MenuItemClickEvent event) {
Window.alert("Menu Item Clicked");

}
}
Reply With Quote
  #7  
Old 9th Nov 2009, 14:25
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,520
Default

First step, read the FAQs about the Developer Console and become familiar with it, which will demystify some of the terminology being used and quite possibly solve the problem for you. You haven't posted a screenshot yet so we don't even know if you've got an issue or just don't realize which elements reside in which space, which is what the Watch Tab will help you understand.
Reply With Quote
  #8  
Old 9th Nov 2009, 15:15
toggle57 toggle57 is offline
Registered Developer
 
Join Date: Nov 2009
Posts: 36
Default

OK - so now i run my application in hosted mode and when the browser pops up with my application I change the url to point to: javascript:isc.showConsole() and I get:

HTTP ERROR: 404
NOT_FOUND
RequestURI=/vantage/sc/system/helpers/Log.html

Is something not installed correctly perhaps?
Reply With Quote
  #9  
Old 9th Nov 2009, 15:30
sjivan sjivan is offline
Registered Developer
 
Join Date: May 2008
Posts: 1,530
Default

Are you sure you've inherited the module com.smartgwt.tools.SmartGwtTools as stated in that FAQ entry?

Sanjiv
Reply With Quote
  #10  
Old 9th Nov 2009, 16:53
toggle57 toggle57 is offline
Registered Developer
 
Join Date: Nov 2009
Posts: 36
Default

Thanks very much Sanjiv, that got me going.

I confess, I did have some trouble finding the documentation I needed to get SmartGwt set up in an eclipse environment so I have to root around on the net and that particular setting was not specified.

The sizes of the items are highlighted and I can see that my menuBar is the size of the vLayout container.

I think this is just a mater of figuring out how to set the background colour of the menuBar. It looks like it must be set to White... the same colour as the rest of my application window... so it just disappears.

Thanks again.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved