Hide tab - Java

Asked

Viewed 450 times

2

I have a program with several tabs, so I will be if the user is ADMIN, based on this I would like to hide/disable some tabs, I have already tested these commands and do not disable the window:

private void SetAbasVisiveis( Usuario usuario){
   if(!usuario.getAdmin()){
        this.pnlMedicamentos.setVisible(false);
        this.pnlMedicamentos.setEnabled(false);
        this.pnlMedicamentos.setFocusable(false)
   }
}

Follows elements

inserir a descrição da imagem aqui

  • I didn’t quite understand your question. According to the user profile do you want to enable or not the tab? And as far as I can tell, this has nothing to do with Netbeans itself (at its core).

  • Why they gave -1?

  • I don’t understand why Netbeans in the title

  • If Net Beans is a problem, just suggest editing, do not downvote

  • For the record, I didn’t downvote

  • Yes, I know, I put in Netbeans because I thought it would help answer why I’m using this environment, but many don’t, I’ve edited. Thanks

Show 1 more comment

1 answer

2


I managed to solve my problem using the following command:

Suffice it to say the tab, of 0 a N (number of tabs of the project) and if you want it enabled = true, or disabled = false

    private void setPermissoes(Usuario usuario){
        if(!usuario.getAdmin()){            
            this.TabbedPane.setEnabledAt(3, false);
            this.TabbedPane.setEnabledAt(2, false);
            this.TabbedPane.setEnabledAt(1, false);
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.