Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Enabling and Disabling a Tab in a JTabbedPane Container

import javax.swing.JButton; import javax.swing.JTabbedPane; public class Main {   public static void main(String[] argv) throws Exception {     JTabbedPane pane = new JTabbedPane();     pane.addTab("Tab Label", new JButton("Button"));     // 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);   } }