newtab.setSelected(false); //reset it else newtab.setSelectedDirectly(false); //turn off first sel = desel = true; //turn on later tabbox.setSelectedTab(newtab); } else { newtab.setSelectedDirectly(true); if (desel) for (Iterator<Component> it = getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); if (tab != newtab && tab.isSelected()) { tab.setSelectedDirectly(false); break;
/** Sets the selected tab. */ /* packge */void selectTabDirectly(Tab tab, boolean byClient) { if (tab == null) throw new IllegalArgumentException("null tab"); if (tab.getTabbox() != this) throw new UiException("Not my child: " + tab); if (tab != _seltab) { if (_seltab != null) _seltab.setSelectedDirectly(false); try { // avoid recursive invoking if (getAttribute(TabboxEngine.ATTR_CHANGING_SELECTION) == null) { setAttribute(TabboxEngine.ATTR_CHANGING_SELECTION, Boolean.TRUE); _seltab = tab; _seltab.setSelectedDirectly(true); if (byClient && _model != null) { Selectable<Object> sm = getSelectableModel(); if (!sm.isSelected(_model.getElementAt(_seltab.getIndex()))) { sm.clearSelection(); sm.addToSelection(_model.getElementAt(_seltab.getIndex())); } } } } finally { removeAttribute(TabboxEngine.ATTR_CHANGING_SELECTION); } if (!byClient) smartUpdate("selectedTab", _seltab); } }