Getting and Setting the Selected Tab in a JTabbedPane Container : TabbedPane « Swing JFC « Java






Getting and Setting the Selected Tab in a JTabbedPane Container

 

import javax.swing.JTabbedPane;

public class Main {
  public static void main(String[] argv) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    // Get the index of the currently selected tab
    int selIndex = pane.getSelectedIndex();

    // Select the last tab
    selIndex = pane.getTabCount() - 1;
    pane.setSelectedIndex(selIndex);
  }
}

   
  








Related examples in the same category

1.Demonstrates the Tabbed PaneDemonstrates the Tabbed Pane
2.A demonstration of the tab wrapping property of JTabbedPaneA demonstration of the tab wrapping property of JTabbedPane
3.A quick test of the JTabbedPane componentA quick test of the JTabbedPane component
4.JTabbedPane class for displaying and manipulatingJTabbedPane class for displaying and manipulating
5.TabbedPane SampleTabbedPane Sample
6.TabbedPane Sample 2TabbedPane Sample 2
7.TabbedPane DemoTabbedPane Demo
8.Laying Out a Screen with JTabbedPaneLaying Out a Screen with JTabbedPane
9.TabPane DemoTabPane Demo
10.Determining When the Selected Tab Changes in a JTabbedPane Container
11.Enable Scrolling Tabs in a JTabbedPane Container
12.Enabling the Selection of a Tab in a JTabbedPane Container Using a Keystroke
13.Setting the Color of a Tab in a JTabbedPane Container
14.Setting the Tool Tip for a Tab in a JTabbedPane Container
15.Enabling and Disabling a Tab in a JTabbedPane Container
16.Setting the Location of the Tabs in a JTabbedPane Container
17.Getting the Tabs in a JTabbedPane Container
18.Retrieve the index of a tab when needed
19.Get the index of the first tab that matches an icon
20.Get the index of the tab by matching the child component
21.Moving a Tab in a JTabbedPane Container
22.Removing a Tab in a JTabbedPane Container
23.Add a tab with a label taken from the name of the component
24.Add a tab with a label at the end of all tabs
25.Add a tab with a label and icon at the end of all tabs
26.Add a tab with a label, icon, and tool tip at the end of all tabs
27.Insert a tab after the first tab
28.Creating a JTabbedPane Container
29.Setting the Size of the Divider in a JSplitPane Container
30.This program demonstrates the tabbed pane component organizer.This program demonstrates the tabbed pane component organizer.