tags:

views:

517

answers:

1
+3  Q: 

Dynamic GWT Menu

+1  A: 

Option (a) sounds better from a conserving resources point of view.

Instead of using the square-root symbol, why don't you use an image (using the com.google.gwt.user.client.ui.Image class)?

I think a more elegant/simple solution might be to use the checkbox class for your menu items. That way you could have automatic ticks/checks instead of having to use an image or the square-root symbol. Also, you will be able to "grey-out" items with setEnabled(false). Otherwise, you will have to write your own widget or add your own functionality to your menu labels in order to "grey-out" items.

prometheus
Thanks Prometheus. I can't see how to make a MenuItem with anything other than Text (which could be HTML). For example, I'd like to make a Panel with a Checkbox and a Label, but GWT doesn't seem to provide that. Also, I can' see any setEnable() option on MenuItem. Am I not looking in the right place?
John
Ah, I was thinking that you could make your own menu and not use MenuItem/MenuBar. If you want to use MenuBar, I would create the MenuItem using html (include the checkbox using an <img> tag) and perhaps change the font color to indicate if an item is not enabled. You could extend the MenuItem/MenuBar classes to add some simple methods that would allow you to change whether an object is selected or enabled. As a last resort, you might want to look into the Smart GWT library (http://www.smartclient.com/smartgwt/showcase/#main) as it has a lot of the functionality that you are looking for.
prometheus