Change the currently displayed tab. Note that the GUI might not update immediately, since this needs to run in the Event dispatch thread. @param index The index of the tab to select
(final int index)
| 1443 | * @param index The index of the tab to select |
| 1444 | */ |
| 1445 | public void selectTab(final int index) { |
| 1446 | currentTabIndex = index; |
| 1447 | updateUndoRedoState(); |
| 1448 | updateTitle(); |
| 1449 | header.rebuild(); |
| 1450 | getCurrentTab().activated(); |
| 1451 | |
| 1452 | // This must be run in the GUI thread |
| 1453 | SwingUtilities.invokeLater(() -> { |
| 1454 | codePanel.removeAll(); |
| 1455 | EditorTab selectedTab = tabs.get(index); |
| 1456 | codePanel.add(selectedTab, BorderLayout.CENTER); |
| 1457 | selectedTab.applyPreferences(); |
| 1458 | selectedTab.requestFocusInWindow(); // get the caret blinking |
| 1459 | // For some reason, these are needed. Revalidate says it should be |
| 1460 | // automatically called when components are added or removed, but without |
| 1461 | // it, the component switched to is not displayed. repaint() is needed to |
| 1462 | // clear the entire text area of any previous text. |
| 1463 | codePanel.revalidate(); |
| 1464 | codePanel.repaint(); |
| 1465 | }); |
| 1466 | } |
| 1467 | |
| 1468 | public void selectNextTab() { |
| 1469 | selectTab((currentTabIndex + 1) % tabs.size()); |
no test coverage detected