waitbar color, 2016a is broken red; how to set to older continuous green?
조회 수: 9 (최근 30일)
이전 댓글 표시
In 2016a waitbar had red color with discrete marks. Older version is continuous green bar.
How to set the waitbar to the old fashion?
댓글 수: 0
채택된 답변
Walter Roberson
2016년 7월 1일
waitbar() creates a figure. In R2016a (did not check other HG2 implementations), that figure has a hidden member in Children which is a JavaWrapper . That JavaWrapper has a JavaPeer which is a javax.swing.JProgressBar which is what is doing the real work. There is no foreground color property above that level.
I have difficulty chasing below that level as I am not very familiar with Java. On my system if I use getForeground on the JavaPeer then the result is java.awt.Color[r=255,g=0,b=0] which would be full red -- but in fact on my system, OS-X El Capitan, the actual color for my progress bars is blue. I can construct a new color and use setForeground on the JavaPeer but it makes no difference. If I use getGraphics on the JavaPeer, and getColor on the result of that, I get told java.awt.SystemColor[i=9] but I have not been able to figure out how the i=9 translates into colors. Meanwhile getBackground on the getGraphics replies with com.apple.laf.AquaImageFactory$SystemColorProxy[r=238,g=238,b=238] which is plausible for the background I observe.
댓글 수: 3
Walter Roberson
2016년 10월 1일
I have not yet been able to figure out how to set the foreground color, but to set the background color:
wb = waitbar(0, 'some message');
wbc = allchild(wb); %you need to get at a hidden child
wbc(1).JavaPeer.setBackground( wbc(1).JavaPeer.getBackground.YELLOW )
The inner expression there about getting the background is just an expression to get at some java.awt.Color, as java.awt.Color objects have some methods for selecting colors. Those methods return new java.awt.Color object, which you then pass in to setBackground
There is a setForeground, but even armed with the hint from Stackoverflow that one needs to setStringPainted(true), I have not been able to change the foreground color on my OS-X system. It might work on other systems. You could try
wbc(1).JavaPeer.setForeground( wbc(1).JavaPeer.getBackground.GREEN )
and you might need to add
wbc(1).JavaPeer.setStringPainted(true)
It doesn't work for me, but it might work for you.
Walter Roberson
2016년 10월 3일
In R2016b on Windows 10, the default foreground color is green.
When I used the lines shown above, I was not able to change the background color (which I was able to change on OS-X.) On the other hand, I could then do
wbc(1).JavaPeer.setForeground( wbc(1).JavaPeer.getBackground.cyan )
wbc(1).JavaPeer.setStringPainted(true)
to end up with the foreground being cyan (where-as on OS-X I was not able to change the foreground.)
The setStringPainted was important: when it is false, the default color is used.
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dialog Boxes에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!