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
You should use the method JTabbedPane. setSelectedIndex(int index) with the index of the tab you want. Show activity on this post. JTabbedpane.
To create a tabbed pane, instantiate JTabbedPane , create the components you wish it to display, and then add the components to the tabbed pane using the addTab method.
Using \t Tab Escape Sequence Character in Java The Escape Sequence, \t is used for tab space. In other words, \t inserts a tab. We use Escape Sequence when we need to format a String . If we use \t at a specific point in a string, it will insert a new tab at that point.
I believe what you are looking for is this.
jTabbedPane1.setEnabledAt(n, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With