Favolas
Favolas

Reputation: 7243

Hide tab from JTabbedPane

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?

Upvotes: 6

Views: 27015

Answers (2)

j2gl
j2gl

Reputation: 726

Short answer:

if (userRole == 1){
   tbpGeral.remove(pnlAdiconarSala)
}

Upvotes: 2

vels4j
vels4j

Reputation: 11298

Here is an clean example

  1. How to Use Tabbed Panes
  2. Inserting, Removing, Finding, and Selecting Tabs

Upvotes: 9

Related Questions