Hey so I've got 20 circles displayed on a screen, I want the user to be able to select only two circles and be able to unselect circles but still only have maximum 2 circles selected. I know how to allow it to only select two circles at a time but not unselect AND how to unselect when only one circle is allowed, I'm just confused now.
This code allows only two circles to be selected but I cannot unselect the circles
Figur vald1 = null, vald2 = null;
Figur fig = (Figur)mev.getSource();
if (vald1 == null){
vald1 = fig;
vald1.setVald(true);
}
else if (vald2 == null && fig1 != vald1){
vald2 = fig;
vald2.setVald(true);
}
and this code allows me to select one circle at a time, and unselect it but not select two circles
if (vald1 != null)
vald1.setVald(false);
if (vald1 == fig)
vald1 = null;
else{
fig.setVald(true);
fig.requestFocusInWindow();
vald1 = fig;