NetBeans:如何在 JTabedPane 中启用/禁用特定选项卡 [英] NetBeans: How to enable/disable specific tab in JTabedPane

查看:23
本文介绍了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 中启用/禁用特定选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆