pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edvin Syse <ed...@sysedata.no>
Subject TabPaneSelectionListener#selectedIndexChanged called twice when first tab is inserted
Date Sat, 04 Jun 2011 07:31:25 GMT
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

Mime
View raw message