I'm wondering if this is as intended or a bug:

When I add a tab to an _empty_ tabpane, two selectedIndexChanged events are called. I.e, when I add a TabPaneSelectionListener to a tabpane and call:

tabpane.getTabs().add(component);

.. my listener fires twice, with previousSelectedIndex set to -1 and then 0.

The two events are fired by line 68 and 72 in TabPane.java:

68            tabPaneListeners.tabInserted(TabPane.this, index);
69
70            // Fire selection change event, if necessary
71            if (selectedIndex != previousSelectedIndex) {
72 tabPaneSelectionListeners.selectedIndexChanged(TabPane.this, selectedIndex);
73            }

Should the if on line 71 take into account that previousSelectedIndex might have been -1 when invoked, like this:

if (selectedIndex != previousSelectedIndex && previousSelectedIndex > -1) {

.. to avoid the double event notification?

-- Edvin

Reply via email to