private static void switchTo(String tabName) { try { container.setSelectedIndex(container.indexOfTab(tabName)); Tab tab = (Tab) container.getSelectedComponent(); tab.refresh(); } catch (IndexOutOfBoundsException e) { System.err.println("Tab selection index out of bound."); e.printStackTrace(); } }