我有具有突片的多个tabs.One一个JDialog
填充复选框的动态列表,并将其添加到JPanel
。这面板添加到该JTabbedPane
。添加到面板禁用复选框没有被禁用
在这个动态列表中,我想根据某些条件禁用一些复选框。
问题是,即使我添加了禁用状态的复选框,它仍然处于启用状态。
我不明白为什么它表现这样或我哪里去错了?
来实现这一目标是如下的代码片段:
private void populateComponents()
{
cwwObjComponentList = cwwObjOprGeneralSetings.getComponentList();
cwwObjComponentName = cwwObjOprGeneralSetings.getComponentName();
cwwObjComponentWithType = cwwObjOprGeneralSetings.getComponentsWithType();
cwwObjPnlComponents.setLayout(new GridLayout(4, 2));
String mwwStrInstallationType = null;
if(Configuration.getParameter(ConfigSettings.InstallationType).equalsIgnoreCase("Enterprise"))
{
mwwStrInstallationType = StoreSettingsFrame.cwwStrEnterpriseInstallation;
}
else if (Configuration.getParameter(ConfigSettings.InstallationType).equalsIgnoreCase("Server"))
{
mwwStrInstallationType = StoreSettingsFrame.cwwStrServerInstallation;
}
else
{
mwwStrInstallationType = StoreSettingsFrame.cwwStrClientInstallation;
}
for (int i = 0; i < cwwObjComponentList.size(); i++)
{
cwwObjCheckbox = new JCheckBox(cwwObjComponentList.get(i));
String mwwStrComponentType = cwwObjComponentWithType.get(cwwObjComponentList.get(i));
if(mwwStrComponentType.equalsIgnoreCase(mwwStrInstallationType))
{
cwwObjCheckbox.setEnabled(true);
}
else
{
cwwObjCheckbox.setEnabled(false);//inspite of disabling few checkboxes, all appear to be enabled
}
cwwObjPnlComponents.add(cwwObjCheckbox);
}
}
为了更快得到更好的帮助,请发布[SSCCE](http://sscce.org/)。 – 2012-02-27 06:25:17
你确定没有别的改变复选框的状态吗? – 2012-02-27 06:53:25
Yup.Checked它。 – shabeena 2012-02-27 06:58:50