How can i solve set problem?

1 view (last 30 days)
Martí Pons
Martí Pons on 6 Dec 2017
Commented: Martí Pons on 8 Dec 2017
jPb = javax.swing.JProgressBar; set(jPb,'StringPainted','on','Value',0,'Indeterminate','off','Foreground',[0 0 1]);
StatusBar(1)=uicontrol('Style','Text','Position',[.03*scrsz(3),.51*scrsz(4) .3*scrsz(3)15],'String','','BackgroundColor','w');
[SB1, ~] = javacomponent(jPb,[.03*scrsz(3) .48*scrsz(4) .3*scrsz(3) 20],F1);
% StatusBar2 - Pitch progression
jPb = javax.swing.JProgressBar; set(jPb,'StringPainted','on','Value',0,'Indeterminate','off','Foreground',[0 0 1]);
StatusBar(2)=uicontrol('Style','Text','Position',[.03*scrsz(3),.46*scrsz(4) .3*scrsz(3) 15],'String','','BackgroundColor','w');
[SB2, ~] = javacomponent(jPb,[.03*scrsz(3) .43*scrsz(4) .3*scrsz(3) 20],F1);
And the error is:
Error using set Parameter must be scalar.
Error in GenDesign/UserInterface (line 95) jPb = javax.swing.JProgressBar; set(jPb,'StringPainted','on','Value',0,'Indeterminate','off','Foreground',[0 0 1]);

Answers (1)

Elizabeth Reese
Elizabeth Reese on 8 Dec 2017
The javacomponent function is undocumented and will change in a future release. I do not recommend using it.
With regard to the error, this is because the types for your inputs do not match what that Java object is expecting. It expects a boolean, int, boolean, and Color respectively.
set(jPb,'StringPainted',1,'Value',0,'Indeterminate',0,'Foreground',java.awt.Color(0,0,1));
  1 Comment
Martí Pons
Martí Pons on 8 Dec 2017
Seriously, you've saved my life. Thank you very much Liz!!

Sign in to comment.

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!