Mega Code Archive

 
Categories / Java Tutorial / Swing
 

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);   } }