I have a loop who adds values in a dataset in 3 series:
for (int j = 0; j < gcArrayList.size(); j++) {
if (j % 3 == 0) {
datasetBar.addValue(Float.parseFloat((String) gcArrayList.get(j)),series1, gcDateList.get(j / 3));
} else if (j % 3 == 1) {
datasetBar.addValue(Float.parseFloat((String) gcArrayList.get(j)),series2, gcDateList.get(j / 3));
} else {
datasetBar.addValue(Float.parseFloat((String) gcArrayList.get(j)),series3, gcDateList.get(j / 3));
}
}
Then I want those dataset to add values in each series only if their checkbox is checked( I have 3 checkboxes for "First array"
, "Second array"
, "Third array"
).
array1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JCheckBox ch = (JCheckBox) e.getSource();
if(ch.isSelected()) {
} else {
}
}
});
Also the checkboxes are in a different class than the method who adds values in datasets.
I don't know how to make the connection between the ActionListener
of the checkbox and the datasetBar.addValue()
.
I tried something like:
if(j % 3 ==0 && array1.isSelected()) ...
I knew it won't work but I think the solution is somewhere in that area... Can anybody help me?
Thanks.