NetBeans: How to enable/disable specific tab in JTabedPane

Jame picture Jame · Oct 1, 2011 · Viewed 17.2k times · Source

I am developing a small desktop application in Netbeans. on my UI i have a JTabbedPane having 3 tabs in it now i come across a situation where i need to temporarily disable 2nd and 3rd tab. How could i do that programatically. Rightnow i am using the following code but its not working:

int n = jTabbedPane1.indexOfTab("Second Tab Name");// This line returns one as expected
jTabbedPane1.getTabComponentAt(n).enable(false);// but i guess some un-expected thing happens here

Answer

Jordonias picture Jordonias · Oct 1, 2011

I believe what you are looking for is this.

jTabbedPane1.setEnabledAt(n, false);