How do I control the size of a checkbox in a programmatic GUI?
13 次查看(过去 30 天)
显示 更早的评论
I have a programmatic GUI and I'm trying to change the size of my checkboxes, but I can't get it to change. I've tried changing fontsize, position height, etc, but haven't figured out the right combination. The stubborn checkboxes remain the same size regardless. Here is my code to create the checkboxes.
hf = figure;
pos = [0, 0.9, 0.2, 0.04];
PlotStr = {'A','B','C','D'};
N = length(PlotStr);
NextRow = 0.064;
dx = 0.3;
TextPos = pos + [0 0 0 0];
CheckPos = pos + [0.3 0 0 0];
for inx = 1:N
textpos = TextPos - inx*[0 NextRow 0 0];
Check1Pos = CheckPos - inx*[0 NextRow 0 0];
PlotText(inx) = uicontrol(hf,'Style','text','String',PlotStr{inx},'Units','normalized','Position',textpos);
Checkbox(inx) = uicontrol(hf,'Style','checkbox','Units','normalized','Position',Check1Pos);
end
0 个评论
回答(1 个)
Jan
2017-3-16
编辑:Jan
2017-3-16
The box itself does not change its size, because this size is controlled by the operating system. The size concerns the area occupied by teh combination of teh box and teh text. See:
figure;
uicontrol('Style', 'checkbox', 'String', 'Box 1', ...
'BackgroundColor', [1,0.3,0.3], ...
'Position', [10, 10, 100, 20]);
uicontrol('Style', 'checkbox', 'String', 'Box 2', ...
'BackgroundColor', [1,0.3,0.3], ...
'Position', [10, 50, 200, 60]);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!