I have a very stupid question, but I can’t seem to figure out the cause of my problem.
I’m using a checkbox, and each time there is a mousePressed event, the checkbox value is switched.
For some reason, when I press with my left mouse button, the checkBox will be checked when setSelected(false) is used.
If I press with my right mouse button, the checkbox will be checked when setSelected(true) is used. This is what I obviously want.
Has anybody an idea why this switch happens between left and right mouse button?
when using a right click on a checkbox you need to filter the inputEvent of the MouseListener to assure that the functionality of your right click will be executed:
Well the URCap would mostly be used on the Teach Pendant so it could be that this problem would not occur (I haven’t tested it yet). However, if the URCap were to be used with the offline simulator, people would probably use the left mouse button which then would result in the opposite functioning of the checkbox which in turn would give an unprofessional feeling.
Like I mentioned, I’m still new and the mouseListener was based on the one used in the example ‘HelloWorldSwing’ but I’ll have a look at the ActionListener and the difference between both and what it entails for operation on the Teach Pendant.
But to answer your last question, a right click is indeed not needed but it seems odd that with a right click the checkbox response as desired while with a left click the opposite occurs (so unchecked icon if SetSelected(true) ).