MATLAB Answers

How to get back red waitbar?

조회 수: 10(최근 30일)
Thomas
Thomas 12 Nov 2014
댓글: Dev-iL 8 Jul 2015
In 2014b the waitbar appearance changed from the cool red to an ugly green windows-style one (btw in help documentation it still says "A wait bar is a figure that displays what percentage of a calculation is complete as the calculation proceeds by progressively filling a bar with red from left to right." ).
How can i revert it back to red?

  댓글 수: 0

로그인 to comment.

채택된 답변

Robert Cumming
Robert Cumming 12 Nov 2014
I played around with the java this afternoon and got this to work:
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;
jContainer = jFigPanel.getComponent(0);
jPanel = jContainer.getComponent(0);
%
jProgressContainer = jPanel.getComponent(0);
% get the progress bar
jProgressBar = jProgressContainer.getComponent(0);
% update the progressbar details
jProgressBar.setBackground ( java.awt.Color.RED );
jProgressBar.setString(''); % set the text to be empty
jProgressBar.setStringPainted(true);
% example of progress bar being updated:
for ii=0:0.02:1
waitbar(ii,hBar)
pause(0.1)
end

  댓글 수: 3

Thomas
Thomas 12 Nov 2014
isnt there a permanent solution? i would modify waitbar.m if possible? how?
Robert Cumming
Robert Cumming 13 Nov 2014
Don't think so. If it's such a problem make your own or use one from the file exchange.
You could put the above code in your own version, or make it a sub function.
Dev-iL
Dev-iL 8 Jul 2015
Nice trick! FYI, the following line has no effect:
jProgressBar.setBackground ( java.awt.Color.RED );

로그인 to comment.

추가 답변(1개)

Michael Haderlein
Michael Haderlein 12 Nov 2014
I'm working with 2014a, but if they didn't change the entire waitbar, you should be able to modify the color this way:
h = waitbar(0,'Please wait...');
hc=get(get(h,'children'),'children');
steps = 1000;
for step = 1:steps
pause(0.001)
waitbar(step / steps)
set(hc(2),'facecolor',rand(1,3))
end
close(h)
Warning: Don't run this code too often, it might cause headache ;-)

  댓글 수: 1

Guillaume
Guillaume 12 Nov 2014
Unfortunately, it doesn't appear to work in 2014b
the child of the waitbar (an axis) does not have any children (that are exposed)

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그

제품


Translated by