I have a method that generates a JPanel with one checkBox. The method has 3 parameters, one of them is a Boolean value that is null. When I use the Boolean parameter into ActionEvent, the system don't recognize it. Also, I use if look because I want that the user could select and unselect the checkBox. Unfortunately, the system never enter when checkBox isSelected. Could you help me, please?
private JPanel getThirdPanelBox(String elementList, String title, Boolean valueMant) {
JPanel thirdPanelBox = new JPanel();
thirdPanelBox.setLayout(new BorderLayout());
thirdPanelBox.add(new JLabel(elementList), BorderLayout.CENTER);
JCheckBox elementListCheckBox = new JCheckBox();
elementListCheckBox.setSelected(false);
elementListCheckBox.addActionListener(actionEvent -> {
if (elementListCheckBox.isSelected())
valueMant = true;
else
valueMant = false;
});
thirdPanelBox.add(elementListCheckBox, BorderLayout.WEST);
return thirdPanelBox;
}