Hide tab from JTabbedPane
Asked Answered
M

2

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?

Moitoso answered 22/12, 2012 at 14:50 Comment(0)
O
9

Here is an clean example

  1. How to Use Tabbed Panes
  2. Inserting, Removing, Finding, and Selecting Tabs
Oxa answered 22/12, 2012 at 14:59 Comment(1)
@Moitoso what is the simple solution to hide and un-hide a tab?Westcott
I
2

Short answer:

if (userRole == 1){
   tbpGeral.remove(pnlAdiconarSala)
}
Indistinguishable answered 18/5, 2013 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.