In this section you will learn how to enable and disable any tab in a TabbedPane component of Java Swing. The tabbed pane container can have one or more tables. All the tabs have a specific area in same place. Whenever you will click on any tab, the components added to the tab will be displayed. Sometimes it is necessary to disable some of the tabs. Following figure shows a frame in which some tabs are disabled:
This program shows the multiple tabs on the frame. These tabs have a suitable name and index number. To enable or disable any tab you can use the setEnabledAt(int index, Boolean value) function. Tabs are by default enabled. Following are some methods and APIs that you can use in your program to enable or disable the tabs.
This is the method of JTabbedPane class, adds the tabs to the panel or other other container component. The parameter description of the function are as follows:
setEnabledAt(int index, Boolean value):
This is the method of JTabbedPane class, enables or disables the tab. This method takes two argument in which, first is the index number of the tab which has to be enabled or disabled and another argument is the boolean value. If the boolean value is TRUE then tab get enabled other wise tab gets disabled.
Here is the code of program:
Posted on: April 14, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles