Java tutorial
import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class Main { public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { JTabbedPane pane = (JTabbedPane) evt.getSource(); int sel = pane.getSelectedIndex(); System.out.println(sel); } }); } }