GUI radio button

19 views (last 30 days)
Jason on 3 Feb 2011
Is it possible to use the radio button to indicate if something is on or off? Right now, whne someone select the radio button it turned green. So for example, I want it to lit green when it's on and red when it's off. How would I go about changing the color of the radio button? How do I get it have to be select all the time. I couldn't find anything in help so I don't know if it's possible. If there is a better way than using radio button, much appreciate. Thanks.

Answers (2)

Daniel Armyr
Daniel Armyr on 7 Feb 2011
Sure you can. Just set the Value property of the radio button to 0 or 1 depending on what you want. To make sure the user doesn't change the value for you, set the Enable property to 'inactive'. That way, the radio button will look like normal, but clicking it won't make a difference.
Another way (Not tested by me) would be to place a small square panel and then change the collor from say green to red. That should be very clear to the user.

Walter Roberson
Walter Roberson on 7 Feb 2011
I don't believe you can control the button color independently of the color of the uicontrol (unless perhaps it is possible using Java.) You can set the color of the uicontrol using the Backgroundcolor property.
Note: the uicontrol Foregroundcolor property does not control the button color: it controls the color of any text you associate with the control.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!