java 从 JTabbedPane 隐藏选项卡
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14003796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide tab from JTabbedPane
提问by Favolas
I'm using Netbeans gui to create a simple app.
我正在使用 Netbeans gui 创建一个简单的应用程序。
This is my structure (the layout is free design):
这是我的结构(布局是免费设计的):
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.
基本上我有 3 个选项卡,想根据条件隐藏其中一个(图像中的选择一个)。就像用户作为某些权限显示该选项卡一样,否则不显示该选项卡。
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?
通过我的实现,我可以隐藏选项卡吗?
回答by vels4j
Here is an clean example
这是一个干净的例子
回答by j2gl
Short answer:
简答:
if (userRole == 1){
tbpGeral.remove(pnlAdiconarSala)
}