How do I control the size of a checkbox in a programmatic GUI?

15 ビュー (過去 30 日間)
John Petersen
John Petersen 2017 年 3 月 16 日
編集済み: Jan 2017 年 3 月 16 日
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

回答 (1 件)

Jan
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]);

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by