tags:

views:

32

answers:

1

Hi,

Newbie question:

I have a Horizontal Panel with a navigation menu in the first cell. When a user selects an option in the navigation menu I wish to populate the second cell to the right of the nav menu with a composite widget.

What I need to do is:

  1. User clicks button in first cell

  2. Check to see if cell 2 got a widget added to it? If yes, remove this widget and replace with another widget based on the selection in the nav menu.

Q: Are there any method to check the number of cells in a Horizontal Panel? I assume that once a widget is removed this number of cells will be decremented by 1.

+2  A: 

The remove() method should do what you want. You pass it the index of the widget you want to remove. Since your first widget in the HorizontalPanel will always be the navigation menu you just need to remove the second widget. If its not there the remove() call will return false. There is also the getWidgetCount() method that can be used to get the total number of widgets residing in the HorizontalPanel.

Refer to the HorizontalPanel java doc

Carnell