Hide tab from JTabbedPane

Favolas picture Favolas · Dec 22, 2012 · Viewed 21.3k times · Source

I'm using Netbeans gui to create a simple app.

This is my structure (the layout is free design ):

enter image description here

Basically I have 3 tabs and want to hide one of them (the select one in the image) based on a condition. Something like if the user as some privileges show that tab, otherwise don't show that tab.

On my code I've tried;

 if (userRole == 1){
    pnlAdiconarSala.setVisible(false);
 }

but this tab is always showing.

With my implementation, can I hide the tab?

Answer