By default, all new tabs are enabled, which means the user can select them. A tab can be disabled to prevent the user from selecting it.
// Create a tabbed pane
JTabbedPane pane = new JTabbedPane(); // Add a tab
pane.addTab("Tab Label", component); // Get index of the new tab
int index = pane.getTabCount()-1; // Determine whether the tab is enabled
boolean enabled = pane.isEnabledAt(index); // Disable the tab
pane.setEnabledAt(index, false);
Related Examples |