I have:
JTabbedPane jtabbedPane = new JTabbedPane();
jTabbedPane.addTab("Tab 1", panel1);
jTabbedPane.addTab("Tab 2", panel2);
jTabbedPane.addTab("Tab 3", panel3);
What I want to do is hide Tab 2 when a condition occurs (say the user isn't permitted to access that tabbed panel.
Yes I know you can do:
jtabbedPane.setEnabled(1, false); // disable Tab 2
which will gray it out, but I want to completely hide it so that the user doesn't even know it's even a possibility in the software. They shouldn't be even aware that it exists.
I do NOT want to do
jtabbedPane.remove(1); // remove Tab 2
because I then have to remove/add on a regular basis.
The only way is to remove it when you don't want to see it, and re-add it later when you do want it visible.
This work in my project.
this.TabbedPane.setEnabledAt(1, 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