/** * Returns the currently selected component for this tabbedpane. * Returns null if there is no currently selected tab. * * @return the component corresponding to the selected tab * @see #setSelectedComponent */ public SComponent getSelectedComponent() { int index = getSelectedIndex(); if (index == -1) { return null; } return ((Page) pages.get(index)).component; }
public void stateChanged(ChangeEvent e) { STabbedPane source = (STabbedPane) e.getSource(); view.setCurrentViewIndex(source.getSelectedIndex()); } });
@Override public void actionPerformed(ActionEvent e) { if (tab.getSelectedIndex() > 0 && "previous".equals(e.getActionCommand())) { int index = tab.getSelectedIndex() - 1; if (tab.isEnabledAt(index)) tab.setSelectedIndex(index); } else if (tab.getSelectedIndex() < tab.getTabCount() - 1 && "next".equals(e.getActionCommand())) { int index = tab.getSelectedIndex() + 1; if (tab.isEnabledAt(index)) tab.setSelectedIndex(index); } tab.requestFocus(); } }
/** * Sets the selected index for this tabbedpane. * * @see #getSelectedIndex * @see SingleSelectionModel#setSelectedIndex */ public void setSelectedIndex(int index) { int oldVal = model.getSelectedIndex(); model.setSelectedIndex(index); propertyChangeSupport.firePropertyChange("selectedIndex", oldVal, this.getSelectedIndex()); }
/** * Sets the component at <i>index</i> to <i>component</i> which must not be null. * An internal exception is raised if there is no tab at that index. * * @param index the tab index where the title should be set * @param component the component for the tab * @see #getComponentAt */ public void setComponentAt(int index, SComponent component) { contents.remove(index); SComponent oldVal = ((Page) pages.get(index)).component; ((Page) pages.get(index)).component = component; contents.add(component, component.getName(), index); component.setVisible(getSelectedIndex() == index); reload(); propertyChangeSupport.firePropertyChange("componentAt", oldVal, ((Page) pages.get(index)).component); }
} else if (index <= getSelectedIndex()) { setSelectedIndex(getSelectedIndex() + 1);
/** * Sets the component at <i>index</i> to <i>component</i>. * An internal exception is raised if there is no tab at that index. * * @param index the tab index where this component is being placed * @param component the component for the tab * @see #getComponent(int) */ public void setComponent(int index, SComponent component) { Page page = (Page) pages.get(index); SComponent oldVal = page.component; if (component != page.component) { if (page.component != null) { contents.remove(page.component); } page.component = component; contents.addComponent(page.component, page.component.getName()); if (getSelectedIndex() == index) card.show(component); reload(); propertyChangeSupport.firePropertyChange("component", oldVal, page.component); } }
if (i == tabbedPane.getSelectedIndex() && tabbedPane.isFocusOwner()) { Utils.optAttribute(device, "foc", tabbedPane.getName()); if (i == tabbedPane.getSelectedIndex()) { cssClassName.append(" STabbedPane_Tab_selected"); } else if (!enabledTab) { cssClassName.append(" STabbedPane_Tab_unselected"); if (i == tabbedPane.getSelectedIndex()) { Utils.optAttribute(device, "style", selectedTabInline); } else if (!enabledTab) {
int selected = getSelectedIndex(); removePageAt(index); if (newTabCount > 0 && selected != -1) {