I have two JRadioButton objects with an ActionListener:
for (JRadioButton b : rightRButtons) {
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Unidade")) {
disableAllComponents(divisiblePanel);
enableAllComponents(unityPanel);
} else if (e.getActionCommand().equals("Divisível")) {
disableAllComponents(unityPanel);
enableAllComponents(divisiblePanel);
}
}
});
}
Somewhere in the code, I select one of them: rdbtnCreationDivisible.setSelected(true);
Those radio buttons, once clicked, are supposed to disable all the components on their respective panels. When I select them using the setSelected method, the components don't get disabled. How can I trigger an action command artificially, so that the ActionListener can "catch" the command?