在等候栏更改条形图的宽度 - MATLAB R2015a

时间:2016-04-01 09:04:28

标签: matlab matlab-figure

如何在Matlab R2015a中控制等待栏内条的宽度?

我刚才提到了以下问题:

waitbar -> length ot the bar figure?

它在Matlab R2012b中完美地与用户提到的解决方案一起工作,但对于R2015a,' Waitbar 1'字符串放在中间,百分比栏根本不会改变宽度....

我使用了以下代码:

HWait = waitbar(0,'Waitbar 1', 'Units', 'normalized', 'Position', [0.25 0.4 0.3 0.08]);
set(HWait,'Name','Tests running');
childrenWaitb = get(HWait, 'Children') ;
set(childrenWaitb, 'Position',[10.8000 13.5000 320 9]);

1 个答案:

答案 0 :(得分:1)

r2014b中等待栏改变了(连同大量图形)。等待栏进度条曾经是一个简单的轴,允许您设置。的位置。

新的等待栏是在java进度条上构建的 - 所以你需要访问java的未记录的功能来更新它:

% Create a progress bar.
hBar = waitbar ( 0, 'Please Wait....' );
% now use java to get to the progress bar
jFrame = get ( hBar, 'JavaFrame' ); % this will throw a warning 
jFigPanel = jFrame.getFigurePanelContainer;
% Now go down through the children of the panel to get the container for the progress bar
jContainer = jFigPanel.getComponent(0);
jPanel = jContainer.getComponent(0);
% Change the location of the panel (ref pixels)
jPanel.setLocation(0,40);
% Change the size of the panel
jPanel.setSize(360,18);
% You then need to repaint and validate for the update to be visible.
jContainer.repaint
jContainer.revalidate