List of usage examples for javax.swing JTabbedPane getSelectedIndex
@Transient public int getSelectedIndex()
From source file:org.sikuli.ide.SikuliIDE.java
private void initTabPane() { tabPane = new CloseableTabbedPane(); tabPane.setUI(new AquaCloseableTabbedPaneUI()); tabPane.addCloseableTabbedPaneListener(new CloseableTabbedPaneListener() { @Override//w w w.j ava2s.c om public boolean closeTab(int i) { EditorPane codePane; try { codePane = getPaneAtIndex(i); tabPane.setLastClosed(codePane.getSrcBundle()); Debug.log(4, "close tab " + i + " n:" + tabPane.getComponentCount()); boolean ret = codePane.close(); Debug.log(4, "after close tab n:" + tabPane.getComponentCount()); if (ret && tabPane.getTabCount() < 2) { (new FileAction()).doNew(null); } return ret; } catch (Exception e) { log(-1, "Problem closing tab %d\nError: %s", i, e.getMessage()); return false; } } }); tabPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(javax.swing.event.ChangeEvent e) { EditorPane codePane = null; JTabbedPane tab = (JTabbedPane) e.getSource(); int i = tab.getSelectedIndex(); if (i >= 0) { codePane = getPaneAtIndex(i); String fname = codePane.getCurrentSrcDir(); if (fname == null) { SikuliIDE.this.setTitle(tab.getTitleAt(i)); } else { ImagePath.setBundlePath(fname); SikuliIDE.this.setTitle(fname); } SikuliIDE.this.chkShowThumbs.setState(SikuliIDE.this.getCurrentCodePane().showThumbs); } updateUndoRedoStates(); if (codePane != null) { SikuliIDE.getStatusbar() .setCurrentContentType(SikuliIDE.this.getCurrentCodePane().getSikuliContentType()); } } }); }