I have a JDialog
which has multiple tabs.One of the tabs populates a dynamic list of checkboxes and adds it to the JPanel
.This panel is then added to the JTabbedPane
.
In this dynamic list, I would like to disable a few checkboxes based on the some condition.
The problem is even when I add a checkbox with disabled state, it is still enabled.
I cannot figure why is it behaving this way or where am I going wrong?
The code snippet used to achieve this is as follows:
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);
}
}