List box with strings, Append those strings in the title of the figures when clicking on it.?

1 次查看(过去 30 天)
I have a List box. Which has strings say red, blue, green. An image is also there. when clicking the red, it should appear on the title of the figure, likewise next by clicking blue, it should append with red, likewise green also.

采纳的回答

Image Analyst
Image Analyst 2012-8-17
Get the string property of the listbox to get all the items in the listbox. Get the value property to get which one on selected and use that as an index into the list of all the items. Then use sprintf() to create your string and use title() to display it atop the image.

更多回答(1 个)

Sean de Wolski
Sean de Wolski 2012-8-17
figure;
imshow('cameraman.tif');
str = {'red','green','blue'};
hL = uicontrol('style','list','string',str,...
'callback',@(src,evt)title(sprintf('Color is: %s',str{get(src,'value')})));
  1 个评论
Sabarinathan Vadivelu
Actually I need that string selected to be displayed at the top. That is okay. The problem is when I select the next string (say green), It have to be appended with red. Displaying red,green. please rectify the problem.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by