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 CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by