Java JTabbedPane selectTab(JTabbedPane pane, String title)

Here you can find the source of selectTab(JTabbedPane pane, String title)

Description

Selects the tab with the specified title.

License

Open Source License

Parameter

Parameter Description
pane The JTabbedPane to use.
title The title to select.

Declaration

public static void selectTab(JTabbedPane pane, String title) 

Method Source Code

//package com.java2s;
/*/*w w  w.j  ava  2 s  .  c o m*/
 * Copyright (c) 1998-2017 by Richard A. Wilkes. All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, version 2.0. If a copy of the MPL was not distributed with
 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This Source Code Form is "Incompatible With Secondary Licenses", as
 * defined by the Mozilla Public License, version 2.0.
 */

import javax.swing.JTabbedPane;

public class Main {
    /**
     * Selects the tab with the specified title.
     *
     * @param pane The {@link JTabbedPane} to use.
     * @param title The title to select.
     */
    public static void selectTab(JTabbedPane pane, String title) {
        int count = pane.getTabCount();
        for (int i = 0; i < count; i++) {
            if (pane.getTitleAt(i).equals(title)) {
                pane.setSelectedIndex(i);
                break;
            }
        }
    }
}

Related

  1. getVirtualWidth(Segment seg, int tabSize)
  2. installPrefsHandler(final Preferences prefs, final String name, final JTabbedPane tabbedPane)
  3. installPrefsHandler(Preferences prefs, String string, JTabbedPane tabbedPane)
  4. isInTabbedContainer(Component c)
  5. moveTab(JTabbedPane tabPane, int srcIndex, int dstIndex)
  6. setDefaultMnemonics(final JTabbedPane jtp)
  7. setSelectComponentTab(Component component)
  8. useTabToChangeFocus(Component comp)