Q:

How to hide tabbed panel in JTabbedPane?

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.

A:

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.

