Java Utililty Methods JTabbedPane

List of utility methods to do JTabbedPane

Description

The list of methods to do JTabbedPane are organized into topic(s).

Method

voidbackwardTab(final Component... component)
The focus goes back to the last component with CTRL + TAB.
for (Component component1 : component) {
    component1.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>(
            Arrays.asList(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK))));
voidcheckHeavyWeightComponents(JTabbedPane tab)
Walk the components of the tab and toggle the heavyweight components visiblity
Component[] comps = tab.getComponents();
int selectedIdx = tab.getSelectedIndex();
for (int i = 0; i < comps.length; i++) {
    toggleHeavyWeightComponents(comps[i], i == selectedIdx);
booleancontainsTab(JTabbedPane tabs, String name)
contains Tab
for (int i = 0; i < tabs.getTabCount(); i++) {
    if (tabs.getTitleAt(i).equals(name)) {
        return true;
return false;
JTabbedPanecreateTabbedPane()
create Tabbed Pane
JTabbedPane tabbedPane = new JTabbedPane();
return tabbedPane;
JTabbedPanefindParentJTabbedPane(JComponent c)
find Parent J Tabbed Pane
if (c == null)
    return null;
Component parent = c.getParent();
while (!(parent instanceof JTabbedPane) && (parent != null)) {
    parent = parent.getParent();
return (JTabbedPane) parent;
JPanelgetConfigPanelFromTabbedPane(JTabbedPane mainTabbedPane)
get Config Panel From Tabbed Pane
JPanel configPanel = null;
Component[] mainComponents = mainTabbedPane.getComponents();
for (Component component : mainComponents) {
    if (component instanceof JScrollPane) {
        if ((component.getName() != null) && (component.getName().equals("mySettopsPane"))) {
            JScrollPane mySettopsPane = (JScrollPane) component;
            Component viewPortComponent = mySettopsPane.getComponent(0);
            JViewport viewPort = (JViewport) viewPortComponent;
...
intgetIndexOf(JTabbedPane tabbedPane, Component component)
get Index Of
int result = -1;
for (int i = 0; i < tabbedPane.getComponentCount(); i++) {
    Component comp = tabbedPane.getComponentAt(i);
    if (comp == component) {
        result = i;
        break;
return result;
JTabbedPanegetJTabbedPaneAncestor(Component c)
get J Tabbed Pane Ancestor
while (c != null) {
    if (c instanceof JTabbedPane) {
        return (JTabbedPane) c;
    c = c.getParent();
return null;
StringgetLineTabs(StyledDocument doc, int startOffset)
get Line Tabs
int i = startOffset;
String s;
try {
    do {
        s = doc.getText(i, 1);
        if ((i > 0 && !"\n".equals(s))) {
            i--;
        } else {
...
intgetNextSubTabIndex(JTabbedPane tabs, int tabIndex)
get Next Sub Tab Index
int nextTabIndex = tabIndex;
for (int i = 0; i < tabs.getComponentCount(); i++) {
    nextTabIndex++;
    if (nextTabIndex == tabs.getComponentCount()) {
        nextTabIndex = 0;
    if (tabs.isEnabledAt(nextTabIndex)) {
        break;
...