我有一个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);
}
}