6

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?

vels4j
  • 11,208
  • 5
  • 38
  • 63
Favolas
  • 6,963
  • 29
  • 75
  • 127

2 Answers2

9

Here is an clean example

  1. How to Use Tabbed Panes
  2. Inserting, Removing, Finding, and Selecting Tabs
vels4j
  • 11,208
  • 5
  • 38
  • 63
2

Short answer:

if (userRole == 1){
   tbpGeral.remove(pnlAdiconarSala)
}
j2gl
  • 706
  • 3
  • 20
  • 28