Example usage for javax.swing JTabbedPane getTitleAt

List of usage examples for javax.swing JTabbedPane getTitleAt

Introduction

In this page you can find the example usage for javax.swing JTabbedPane getTitleAt.

Prototype

public String getTitleAt(int index) 

Source Link

Document

Returns the tab title at index.

Usage

From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java

private void selectTabPane(CollectableGenericObjectWithDependants clct) {
    // select tab in state
    //Integer iState = (Integer)clct.getField(NuclosEOField.STATENUMBER.getMetaData().getField()).getValueId();
    DynamicAttributeVO vo = clct.getGenericObjectCVO()
            .getAttribute(NuclosEOField.STATENUMBER.getMetaData().getId().intValue());
    if (vo == null)
        return;//from  w w w  .  j  a v  a  2s .  c  o m
    Integer iState = (Integer) vo.getValue();

    String strTabName = getPreferences().get(TABSELECTED, "");
    for (StateVO voState : StateDelegate.getInstance().getStatesByModule(getModuleId()))
        if (voState.getNumeral().equals(iState)) {
            if (voState.getTabbedPaneName() != null)
                strTabName = voState.getTabbedPaneName();
            break;
        }

    JComponent jcomp = layoutrootDetails.getRootComponent();
    List<JTabbedPane> lst = new ArrayList<JTabbedPane>();

    searchTabbedPanes(jcomp, lst);

    for (JTabbedPane tabPane : lst)
        for (int i = 0; i < tabPane.getTabCount(); i++)
            if (org.apache.commons.lang.StringUtils.equals(tabPane.getComponentAt(i).getName(), strTabName)
                    || org.apache.commons.lang.StringUtils.equals(tabPane.getTitleAt(i), strTabName)) {
                tabPane.setSelectedIndex(i);
                break;
            }

    adjustTabbedPanes(lst);
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private void rebuildReportMenu() {
    final XulComponent reopenMenu = context.getView().getXulComponent("window.reports-area",
            XulComponent.class);
    if (reopenMenu == null) {
        return;/*from w w  w  .j  a  va 2s  .  c  o  m*/
    }

    final List<XulComponent> xulComponents = reopenMenu.getChildNodes();
    final XulComponent[] objects = xulComponents.toArray(new XulComponent[xulComponents.size()]);
    for (int i = 0; i < objects.length; i++) {
        final XulComponent object = objects[i];
        reopenMenu.removeChild(object);
    }

    final JTabbedPane tabbedPane = getReportEditorPane();
    final int count = tabbedPane.getTabCount();
    if (count > 0) {
        reopenMenu.addChild(new SwingMenuseparator(null, null, null, "menu-separator")); // NON-NLS
        for (int i = 0; i < count; i++) {
            final Component at = tabbedPane.getTabComponentAt(i);
            final String tabName;
            if (at instanceof TabRenderer) {
                final TabRenderer renderer = (TabRenderer) at;
                tabName = renderer.getTitle();
            } else {
                tabName = tabbedPane.getTitleAt(i);
            }
            final SelectTabAction action = new SelectTabAction(i, tabName);
            final ActionSwingMenuitem actionSwingMenuitem = context.getView().createMenuItem(action);
            actionSwingMenuitem.setReportDesignerContext(context);
            reopenMenu.addChild(actionSwingMenuitem);
        }
    }
}

From source file:org.sikuli.ide.SikuliIDE.java

private void initTabPane() {
    tabPane = new CloseableTabbedPane();
    tabPane.setUI(new AquaCloseableTabbedPaneUI());
    tabPane.addCloseableTabbedPaneListener(new CloseableTabbedPaneListener() {
        @Override// w w  w  .  j a v  a2s . c  om
        public boolean closeTab(int i) {
            EditorPane codePane;
            try {
                codePane = getPaneAtIndex(i);
                tabPane.setLastClosed(codePane.getSrcBundle());
                Debug.log(4, "close tab " + i + " n:" + tabPane.getComponentCount());
                boolean ret = codePane.close();
                Debug.log(4, "after close tab n:" + tabPane.getComponentCount());
                if (ret && tabPane.getTabCount() < 2) {
                    (new FileAction()).doNew(null);
                }
                return ret;
            } catch (Exception e) {
                log(-1, "Problem closing tab %d\nError: %s", i, e.getMessage());
                return false;
            }
        }
    });

    tabPane.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(javax.swing.event.ChangeEvent e) {
            EditorPane codePane = null;
            JTabbedPane tab = (JTabbedPane) e.getSource();
            int i = tab.getSelectedIndex();
            if (i >= 0) {
                codePane = getPaneAtIndex(i);
                String fname = codePane.getCurrentSrcDir();
                if (fname == null) {
                    SikuliIDE.this.setTitle(tab.getTitleAt(i));
                } else {
                    ImagePath.setBundlePath(fname);
                    SikuliIDE.this.setTitle(fname);
                }
                SikuliIDE.this.chkShowThumbs.setState(SikuliIDE.this.getCurrentCodePane().showThumbs);
            }
            updateUndoRedoStates();
            if (codePane != null) {
                SikuliIDE.getStatusbar()
                        .setCurrentContentType(SikuliIDE.this.getCurrentCodePane().getSikuliContentType());
            }
        }
    });

}