Position group docked figures proportional to screen size (javaframe)

8 次查看(过去 30 天)
Hi! I docked 7 figures within a group (javaframe?). I can't define a position for the whole group. Could you help me? I followed this suggestions by Jan to create the group:
I read few articles on https://undocumentedmatlab.com/ but I could not solve it for now.
My code is something like this:
close all
clear all
f1=figure('WindowStyle', 'normal', 'Name', '1', 'NumberTitle', 'off');
f2=figure('WindowStyle', 'normal', 'Name', '2', 'NumberTitle', 'off');
f3=figure('WindowStyle', 'normal', 'Name', '3', 'NumberTitle', 'off');
f4=figure('WindowStyle', 'normal', 'Name', '4', 'NumberTitle', 'off');
f5=figure('WindowStyle', 'normal', 'Name', '5', 'NumberTitle', 'off');
f6=figure('WindowStyle', 'normal', 'Name', '6', 'NumberTitle', 'off');
f7=figure('WindowStyle', 'normal', 'Name', '7', 'NumberTitle', 'off');
figH = gobjects(1, 7);
figH(1, 1)=f1;
figH(1, 2)=f2;
figH(1, 3)=f3;
figH(1, 4)=f4;
figH(1, 5)=f5;
figH(1, 6)=f6;
figH(1, 7)=f7;
name_files={'1','2','3','4','5','6','7'};
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
pixels=get(0,'screensize');
myGroup = desktop.addGroup('myGroup');
desktop.setGroupDocked('myGroup', 0);
myDim = java.awt.Dimension(4, 2);
desktop.setDocumentArrangement('myGroup', 2, myDim)
bakWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
for iFig = 1:7
figH(1, iFig).Position=[0 0 800 300]; %desired position
figH(1, iFig).WindowStyle='docked';
drawnow;
pause(0.05);
set(get(handle(figH(iFig)), 'javaframe'), 'GroupName', 'myGroup');
end
desktop.setDocumentArrangement('myGroup', 1, myDim)
  3 个评论
Mario Malic
Mario Malic 2021-3-2
See figure properties: Position and Units. If you set Units to normalized, you don't need to work with resolution.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by