Getting and Setting the Selected Tab in a JTabbedPane Container
import javax.swing.JTabbedPane;
publicclass Main {
publicstaticvoid 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);
}
}