Wrap your javacomponent code as follows:
oldWarningState = warning('off', 'MATLAB:ui:javacomponent:FunctionToBeRemoved');
[hjcomponent, hcontainer] = javacomponent(...
warning(oldWarningState);
If you have multiple calls to javacomponent in your GUI code, you may wish to revert the warning state only at the end of your GUI creation code (take care to do it even in case of exceptions or early function bail-outs, so that you don't get stuck forever with the warning turned off.
If you want to permanently turn off this warning, run warning('off','MATLAB:ui:javacomponent:FunctionToBeRemoved') in your Matlab Command Window and then you won't need to modify the code at all.
General note: to know which warning identifier cause each warning that is displayed, run the following:
This will include the display of the warning ID ('MATLAB:ui:javacomponent:FunctionToBeRemoved' in this specific case) next to the warning message. For example:
Warning: JAVACOMPONENT will be removed in a future release. For more information see UI Alternatives for MATLAB Apps on mathworks.com. (Type "warning off MATLAB:ui:javacomponent:FunctionToBeRemoved" to suppress this warning.)
Best Answer