dimanche 1 mars 2015

How to select a JRadioButton from ButtonGroup?



I try to do an image creator program in java (with squares/circles/etc) I have a few JRadioButtons in a ButtonGroup that symbolizes my program's "mode" (if I draw a circle, something else/if I move the objects). When I click on different modes, the "mode" changes and I'm able to do what I want. My problem is when I try to change the mode by double-clicking on an object. I do it in a MouseListener. I'm able to select the object, to change the "mode", but I can't change the selected JRadio Button on my ButtonGroup. I searched for a while (since the setSelected() is not working). I know that ButtonGroup can have only a button selected at once. How could I deselect the curent one and select the one I need (the first one). Thank you for any advices.




Aucun commentaire:

Enregistrer un commentaire