Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

ComboBox : removeAllItems doesn't remove icons ?

Thomas Pitrou
1 decade ago Mar 12, 2010 11:42am

Hi folks !

I have note a strange thing on the comboBox if that component contains items with icons. The method to remove items (removeAllitems) doesn't seem to work properly because after calling that method the selected icon's item is still displayed.
See my code below to reproduce that case under Vaadin 6.2.5.

@SuppressWarnings("serial")
public class ApplicationTest extends Application implements Button.ClickListener {
	private Window mainWindow = new Window("ComboBoxIconTest");
	private ComboBox cb = new ComboBox("Test");
	private Button btClear = new Button("Clear Button");

	@Override
	public void init() {
		setTheme("runo");
		setMainWindow(mainWindow);
		cb.setImmediate(true);
		btClear.setImmediate(true);
		btClear.addListener(this);
		loadComboBox();
		mainWindow.addComponent(cb);
		mainWindow.addComponent(btClear);
	}

	private void loadComboBox() {
		cb.addItem(1);
		cb.setItemCaption(1, "icon test");
		cb.setItemIcon(1, new ThemeResource("icons/16/ok.png"));
	}

	@Override
	public void buttonClick(ClickEvent event) {
		if (event.getButton().equals(btClear)) {
			cb.removeAllItems();
		}
	}

}

Can you tell if that normal or maybe I'm doing something wrong.
Thanks in advance !

Thomas Pitrou
1 decade ago Mar 16, 2010 9:27am
Evgeniy Zherebin
1 decade ago Oct 07, 2010 5:40am