本文介绍了NetBeans:如何在JTabedPane中启用/禁用特定选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Netbeans中开发一个小型桌面应用程序.在我的UI上,我有一个JTabbedPane
,其中有3个选项卡,现在我遇到需要临时禁用第二个和第三个选项卡的情况.我怎么能以编程方式做到这一点.现在,我正在使用以下代码,但无法正常工作:
I am developing a small desktop application in Netbeans. on my UI i have a JTabbedPane
having 3 tabs in it now i come across a situation where i need to temporarily disable 2nd and 3rd tab. How could i do that programatically. Rightnow i am using the following code but its not working:
int n = jTabbedPane1.indexOfTab("Second Tab Name");// This line returns one as expected
jTabbedPane1.getTabComponentAt(n).enable(false);// but i guess some un-expected thing happens here
推荐答案
我相信您正在寻找的是这个东西.
I believe what you are looking for is this.
jTabbedPane1.setEnabledAt(n, false);
这篇关于NetBeans:如何在JTabedPane中启用/禁用特定选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!